PHP 中的新行.如何? [英] new lines in PHP. how?
本文介绍了PHP 中的新行.如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
代码:
<?php
echo "Hello World!\nSecond line";
?>
我试图将其显示为两个单独的行,但换行符不起作用,而是在两者之间打印了一个空格.我试过 \r\n 以及 .PHP_EOL.以及将字符串放在单引号中.它们似乎都不起作用.那么如何在 PHP 中打印新行呢?
I'm trying to display this as two separate lines but the line break character doesn't work and instead a space gets printed inbetween the two. I've tried \r\n as well as .PHP_EOL. as well as placing the string in single quotes. None of them seems to work. So how do I print new lines in PHP?
我正在开发 phpDesigner 8
I'm working on phpDesigner 8
推荐答案
使用 nl2br()
将新行转换为 HTML <br/>
元素:
<?php
echo nl2br("Hello World!\nSecond line");
?>
这篇关于PHP 中的新行.如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文