Line breaks have stopped working.

f1.p183

New Member
Messages
15
Reaction score
0
Points
0
I can't get PHP_EOL or \r\n to give me a line break.

I've not used my account for a few weeks and I recently logged in because I wanted to try changing some of my PHP Mysql to use PDO.

Has anything been updated recently that would stop PHP_EOL line breaks from working ?
Whenever I add PHP_EOL to an echoed string in single quotes now it no longer works and the output comes out as one long string.

ie: echo 'This is a line of text'.PHP_EOL;
echo 'And this is another'
ouputs as This is a line of textand this is another

Thanks in advance for any help.
 

denzil

New Member
Messages
134
Reaction score
3
Points
0
Just do: echo '<br />' or is it too much effort to update everywhere?
 
Last edited:

f1.p183

New Member
Messages
15
Reaction score
0
Points
0
Thanks for this suggestion denzil. I'm still quite new to php and I didn't know about this.

Still curious as to why PHP_EOL and \r\n has stopped working but as this has the same effect I won't worry about it too much. Thanks again.
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
When displayed as HTML PHP_EOL ( \n in *nix ), does not cause a line break unless you are between [ pre ] tags.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
<br/> isn't semantic. HTML is a structuring language, not a formatting one. When producing HTML, you shouldn't be thinking in terms of presentation but document structure. Pick appropriate elements (such as <p> or a list), then style the result with CSS. You can use the white-space property to preserve newlines in any element, or use margins to put space between elements.

Note you can use
PHP:
, [html] or [code] tags (as appropriate) to separate and format code.

For reference: §9.1 of the HTML standard describes how [URL="http://www.w3.org/TR/html401/struct/text.html#h-9.1"]white space[/URL] should be handled by user agents.
 
Last edited:

callumacrae

not alex mac
Community Support
Messages
5,257
Reaction score
97
Points
48
PHP_EOL will never have worked as an HTML white space ;-)
 
Top