When do I use PHP_EOL instead of \n and vice-versa ? Ajax/Jquery client problem

后端 未结 5 680
渐次进展
渐次进展 2020-12-01 08:26

I have a php parser that split a given string by line-breaks, doing something like this:

$lines = explode(PHP_EOL,$content);

The parser wor

5条回答
  •  日久生厌
    2020-12-01 08:45

    PHP_EOL is a constant holding the line break character(s) used by the server platform. In the case of Windows, it's \r\n. On *nix, it's \n. You apparently have a Windows server.

    If you were on a *nix server, that change wouldn't have fixed it, because it would be \n. If you are sending data to the client (i.e. the browser), you should use \r\n to ensure line breaks are recognized.

提交回复
热议问题