Hi. I read that this constant provides a newline for different operating systems. Why then in the example

<?php echo 'TOO'.PHP_EOL.'TOO'.PHP_EOL.'TOO' ?> 

instead of strings, only spaces appear? What is its area of ​​application? Just add header("Content-type: text/plain"); helps.

    4 answers 4

    Apparently you look through the browser. In the page code look there will be a line feed. And for the browser you need to set

    alt text

    • Checked in the files there is an entry with the translation of the line. Do not tell me how is writing to the database? - koza4ok
    • Please rephrase the question. because if the record of the PHP_EOL character is most likely 0 or null, but it may also not be checked by \ r \ n - binliz
    • This variable $ str = 'TOO'.PHP_EOL.'TOO'.PHP_EOL.'TOO' is inserted into the database. - koza4ok
    • Yes, it normally casts like a line feed - binliz
    • @ koza4ok, and check yourself anyway? - user6550

    So better understandable:

     <?php echo 'TOO'.'TOO'.'TOO'."</br>"; echo 'TOO'.PHP_EOL.'TOO'.PHP_EOL.'TOO'; echo "<pre>".'TOO'.PHP_EOL.'TOO'.PHP_EOL.'TOO'."</pre>"; ?> 

      PHP_EOL can contain only two values ​​either \r\n for windows platforms or \n for others. Previously, before version 5.4, there was a third possible value of \r for Mac OSX, but in older versions this is no longer relevant.

        You can use nl2br ()

         <?php echo nl2br('TOO'.PHP_EOL.'TOO'.PHP_EOL.'TOO');