Home > Backend Development > PHP Tutorial > PHP PHP_EOL newline character

PHP PHP_EOL newline character

步履不停
Release: 2023-04-06 22:30:01
Original
3548 people have browsed it

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";
?>
Copy after login


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 : '
');

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";
}
?>
Copy after login

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!

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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template