Home  >  Article  >  Backend Development  >  PHP_EOL newline parsing in php

PHP_EOL newline parsing in php

不言
不言Original
2018-04-08 15:22:052309browse

When I read the manual, I found the variable PHP_EOL. After checking the information, it turned out that it is equivalent to the newline character. In PHP, PHP_EOL can be used instead to improve the source code level portability of the code.

Use in unix series\n
Use in windows series\r\n
Use in mac\r
PHP_EOL can be used instead in PHP to improve the source code level portability of the code

For example:

##Copy code The code is as follows:

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

We can use the function get_defined_constants() to get all PHP constants.


The above is the detailed content of PHP_EOL newline parsing in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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