Heim  >  Artikel  >  Backend-Entwicklung  >  php代码中使用换行及(n或rn和br)的应用_PHP教程

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

WBOY
WBOYOriginal
2016-07-21 15:13:31711Durchsuche

代码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

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/326495.htmlTechArticle代码a: 复制代码 代码如下: ?php echo'hello/br'; echo'world!'; ? output: helllo world! 代码b: 复制代码 代码如下: ?php echo'hello\n';//unix系统使用\n;window...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn