\n vs. PHP_EOL vs.
?

后端 未结 6 1862
粉色の甜心
粉色の甜心 2020-12-04 18:04

In most cases, as for one interactive website, when we output multiple lines of contents to web client browser, in my opinion,
is much more prefer

6条回答
  •  攒了一身酷
    2020-12-04 18:50

    You can create a function with Flavio's code, that always sets the correct newline, no matter if you run it on the shell or in the browser:

    /i', PHP_EOL, $string);
      return nl2br($string);
    }
    
    
    print nl("One\nTwo
    Three\r\nFour
    Five Six" . PHP_EOL); ?>

提交回复
热议问题