Use the PHP_EOL
constant, which is automatically set to the correct line break for the operating system that the PHP script is running on.
Note that this constant is declared since PHP 5.0.2.
<?php
echo "Line 1" . PHP_EOL . "Line 2";
?>
For backwards compatibility:
if (!defined('PHP_EOL')) {
switch (strtoupper(substr(PHP_OS, 0, 3))) {
// Windows
case 'WIN':
define('PHP_EOL', "
");
break;
// Mac
case 'DAR':
define('PHP_EOL', "
");
break;
// Unix
default:
define('PHP_EOL', "
");
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…