Home  >  Article  >  Backend Development  >  PHP PHP_EOL newline character

PHP PHP_EOL newline character

步履不停
步履不停Original
2019-06-26 17:12:493490browse

PHP PHP_EOL newline character

Line break
Unix series uses\n
windows series uses\r\n
mac uses\r
You can use PHP_EOL in PHP instead. To improve the source code level portability of the code

For example:

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


Similarly commonly used ones are
DIRECTORY_SEPARATOR

can Use the function get_defined_constants() to get all PHP constants

Usage: Define constant EOL

define ('EOL',(PHP_SAPI == 'cli' ) ? PHP_EOL : 'df250b2156c434f3390392d09b1c9563');

php_sapi_name — Returns the interface type between the web server and PHP

Description

string php_sapi_name ( void )

Returns a lowercase string describing the interface type used by PHP (the Server API, SAPI). For example, under the CLI of PHP this string would be "cli", and under Apache there may be several different values, depending on the specific SAPI used. Possible values ​​are listed below.

<?php
$sapi_type = php_sapi_name();
if (substr($sapi_type, 0, 3) == &#39;cgi&#39;) {
    echo "You are using CGI PHP\n";
} else {
    echo "You are not using CGI PHP\n";
}
?>

Recommended related PHP video tutorials: 《PHP Video Tutorial》

The above is the detailed content of PHP PHP_EOL newline character. 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
Previous article:php life cycleNext article:php life cycle

Related articles

See more