我试着打印这样的新行。但它不起作用。然后我试着用PHP_EOL
打印它,但没有成功。为什么。我的PHP版本是5.6,带有XAMPP。我在Windows 8.1上运行。这是我的代码
<?php
echo "Add a new line n Add a second new line";
?>
它将输出显示为
添加新行添加第二个新行
我想知道为什么不工作
\条目:
<?php
echo nl2br("Add a new line n Add a second new line");
?>
尝试以下代码:页面内容类型问题
<?php
header('Content-type: text/plain');
echo "Add a new line n Add a second new line";
?>
如果你想在网页上增加一行,你应该使用
在文件中写入数据时,请使用PHP_EOL或\n,\r,\n\r
来自php手册:
// Outputs: This will not expand: n a newline
echo 'This will not expand: n a newline';
// Outputs: Variables do not $expand $either
echo 'Variables do not $expand $either';