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

WBOY
Libérer: 2016-07-21 15:13:31
original
714 Les gens l'ont consulté

代码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...
Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!