Home > php教程 > php手册 > php中的PHP_EOL换行符详细解析

php中的PHP_EOL换行符详细解析

WBOY
Release: 2016-06-06 20:27:09
Original
1732 people have browsed it

看手册时发现PHP_EOL这个变量,查了下资料,原来是相当于换行符。在PHP中可以用PHP_EOL来替代,以提高代码的源代码级可移植性

在unix系列用 \n
在windows系列用 \r\n
在mac用 \r
PHP中可以用PHP_EOL来替代,,以提高代码的源代码级可移植性

比如: 

复制代码 代码如下:


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


我们可以用函数get_defined_constants()来获取所有PHP常量。
Related labels:
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