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

WBOY
Release: 2016-05-17 09:07:04
Original
1059 people have browsed it

代码a:

复制代码 代码如下:

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

output:
helllo
world!
代码b:
复制代码 代码如下:

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

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