Home > php教程 > php手册 > php代码中使用换行及(n或rn和br)的应用

php代码中使用换行及(n或rn和br)的应用

WBOY
Release: 2016-06-13 11:55:28
Original
938 people have browsed it

代码a:

复制代码 代码如下:


echo'hello';
echo'world!';
?>


output:
helllo
world!
代码b:

复制代码 代码如下:


echo'hello\n';//unix系统使用\n;windows系统下\r\n
echo'world!';
?>


output:
helloworld!
分析:浏览器识别不了\n或\r\n,这两个换行符是文本换行符,文本文件有效;在网页中查看HTML源代码可以发现代码b成功实现了换行
总结:如果需要将结果输出到浏览器或打印到显示器,代码中使用;如果只是在源代码中换行,则使用\n或\r\n
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template