Home >Backend Development >PHP Tutorial >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) == 'cgi') { 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!