当我试图在PHP中测试一个heredoc构造时,我发现了一个谜。我不知道这段代码有什么问题:
<?php
$author = "Scott Adams";
$out = <<<_END
Normal people believe that if it ain't broke, don't fix it.
Engineers believe that if it ain't broke, it doesn't have enough
features yet.
- $author.
_END;
echo $out;
?>根据我的书,这里没有必要使用\n来放置linefeed,只需键入enter按钮即可。但是它不使用linefeed,只打印文本,仅此而已。我的apache服务器是否有问题,或者可能是配置错误?我使用它与默认设置。
谢谢你的帮助。
发布于 2014-11-09 16:54:49
在浏览器中,所有空白(制表符、新行、多个空格)都被折叠.
如果要在浏览器中显示新行,则需要添加html换行:
echo nl2br($out);https://stackoverflow.com/questions/26830370
复制相似问题