Line breaks have stopped working.

Discussion in 'Scripts, 3rd Party Apps, and Programming' started by f1.p183, Aug 13, 2011.

  1. f1.p183

    f1.p183 New Member

    Messages:
    15
    Likes Received:
    0
    Trophy 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.
     
  2. denzil

    denzil New Member

    Messages:
    134
    Likes Received:
    3
    Trophy Points:
    0
    Just do: echo '<br />' or is it too much effort to update everywhere?
     
    Last edited: Aug 13, 2011
  3. f1.p183

    f1.p183 New Member

    Messages:
    15
    Likes Received:
    0
    Trophy 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.
     
  4. descalzo

    descalzo Grim Squeaker Community Support

    Messages:
    9,375
    Likes Received:
    327
    Trophy Points:
    83
    When displayed as HTML PHP_EOL ( \n in *nix ), does not cause a line break unless you are between [ pre ] tags.
     
  5. misson

    misson Community Paragon Community Support

    Messages:
    2,572
    Likes Received:
    72
    Trophy 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 [codetags (as appropriateto 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[/URLshould be handled by user agents.
     
    Last edited: Aug 13, 2011
  6. callumacrae

    callumacrae not alex mac Community Support

    Messages:
    5,257
    Likes Received:
    97
    Trophy Points:
    48
    PHP_EOL will never have worked as an HTML white space ;-)
     
  7. f1.p183

    f1.p183 New Member

    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    0
    Thanks for all the replies. Most helpful.
     

Share This Page