When do I use the PHP constant “PHP_EOL”?

前端 未结 19 2291
攒了一身酷
攒了一身酷 2020-11-22 06:21

When is it a good idea to use PHP_EOL?

I sometimes see this in code samples of PHP. Does this handle DOS/Mac/Unix endline issues?

19条回答
  •  醉话见心
    2020-11-22 07:21

    You are writing code that predominantly uses single quote strings.

    echo 'A $variable_literal that I have'.PHP_EOL.'looks better than'.PHP_EOL;  
    echo 'this other $one'."\n";
    

提交回复
热议问题