Reputation: 15724
I have a page written with php where, for some reason, all of the plain html content of the file index.php goes on one line (look at the source) The white space is preserved, but all the new-lines disappear.
I cannot come up with any reason why this would happen, short of a syntax error, but I went through with a fine toothed comb, and found nothing out of place. This only happens on the index.php page.
Anyone have any Ideas what I should be looking for? I can post more code if necessary.
<?php
//...
include('ssi/header.php');
?>
<div>
<section id="charters">
<h2><a href="charters.php">Tanker Chartering</a></h2>
<!-- ... -->
The above code evaluates to something like this:
<div> <section id="charters"> <h2><a href="charters.php">Tanker ...
Upvotes: 0
Views: 717
Reputation: 9558
It's probably the encoding of the file combined with the transfer mode on the ftp from which you downloaded/uploaded the file. Try using something like notepad2, and saving the file in UTF-8 rather than ANSI. Also upload/download with your FTP program in binary not ASCII. That stopped all of my newline issues with PHP.
Upvotes: 1
Reputation: 12867
could it be that your hosting provider is doing some kind of minimization for you? no newlines means less characters pused down the wire.
Upvotes: 0
Reputation: 723
Maybe you have linux server and you're using windows system. Different operating systems use different new line characters. Also, for one server my FTP client uploaded it with wrong formatting, and missed every line break.
Also applications like Notepad++ gives you the ability to change formatting and linebreaks.
Upvotes: 3