Home > php教程 > php手册 > php中的PHP_EOL换行符

php中的PHP_EOL换行符

WBOY
Release: 2016-06-13 10:57:56
Original
1021 people have browsed it

看手册时发现PHP_EOL这个变量,查了下资料,原来是相当于换行符

在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"; 

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

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

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template