PHP's universal newline character PHP_EOL




 Constant official reference: http://cn.php.net/manual/en/reserved.constants.php

For newlines, individual operating systems do things their own way.

For unix/Linux\n for
windows series\r\n
for mac\r

PHP_EOL can be used instead in PHP to improve the source-level portability of the code,
such as:

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

Similar commonly used
DIRECTORY_SEPARATOR
can use the function get_defined_constants() to get all PHP constants

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

Post a Comment

Previous Post Next Post