php 中的换行 PHP_EOL

180it 2020-09-28 PM 1476℃ 0条

换行符

unix系列用 \n

windows系列用 \r\n

mac用 \r

PHP中可以用PHP_EOL来替代,以提高代码的源代码级可移植性

如:

<?php

echo PHP_EOL;
//windows平台相当于    echo "\r\n";
//unix\linux平台相当于    echo "\n";
//mac平台相当于    echo "\r";

类似常用的还有

DIRECTORY_SEPARATOR

可以用函数get_defined_constants()来获取所有PHP常量

<?php

print_r(get_defined_constants());//get_defined_constants()返回所有常量数组



get_defined_constants 返回所有常量数组

参考链接:https://www.cnblogs.com/codefor/archive/2011/06/18/2084300.html

支付宝打赏支付宝打赏 微信打赏微信打赏

如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!

标签: none

php 中的换行 PHP_EOL