\ n和< br/>之间的区别在PHP中 [英] The difference between \n and <br /> in php

查看:102
本文介绍了\ n和< br/>之间的区别在PHP中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过教程学习php.我认识到在php中
有时会这样使用

I was studying php with tutorial. I recognized that in php
is sometimes use like this

echo $myString."<br />"

突然,教程"\ n"中出现了另一个,我感到困惑.我可以像使用

Suddenly, there came another in the tutorial "\n" and I got confused. Can I use it just like I use

<br />

?

是这样吗?

echo $mySting."\n"

它像html标签吗? 之间有什么区别

Is it like a html tag? What's the difference between

<br /> and \n?

推荐答案

<br />是HTML换行符,而\n是源代码中的换行符.

<br /> is a HTML line-break, whereas \n is a newline character in the source code.

换句话说,当您以呈现的HTML格式查看页面时,<br />将换行,而在查看源代码时,\ n将换行.

In other words, <br /> will make a new line when you view the page as rendered HTML, whereas \n will make a new line when you view the source code.

或者,如果要输出到控制台而不是Web浏览器将呈现的位置,则\n将在控制台输出中创建换行符.

Alternatively, if you're outputting to a console rather than somewhere that will be rendered by a web browser then \n will create a newline in the console output.

这篇关于\ n和&lt; br/&gt;之间的区别在PHP中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆