简体   繁体   English

有什么区别“ <br /> \\ n“;和” <br /> “;

[英]What is the difference between “<br />\n”;and “<br />”;

I am new to php,there is a statement confused me. 我是php新手,有一个声明让我很困惑。

<?php
$dom=new Document();
$dom->loadHTMLFile('http://php.net');
$xml = simplexml_import_dom($dom);
$nodes = $xml->xpath('//a[@href]');
foreach ($nodes as $node) {
    echo $node['href'], "<br />\n";
}
?>

If we change echo $node['href'], "<br />\\n"; 如果我们改变echo $node['href'], "<br />\\n"; into echo $node['href']."<br />"; 进入echo $node['href']."<br />"; ,it has the same effect,same output in my web page,i want to know What is the difference between echo "some string",<br />\\n"; and echo
"some string".<br />";
,它有相同的效果,我的网页输出相同,我想知道echo "some string",<br />\\n";echo
"some string".<br />";
之间有什么区别
echo
"some string".<br />";
echo
"some string".<br />";
?
echo
"some string".<br />";

<br /> is a HTML line-break, whereas \\n is a newline character in the source code. <br />是一个HTML换行符,而\\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. 换句话说,当您将页面视为呈现的HTML时, <br />将创建一个新行,而当您查看源代码时, \\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. 或者,如果您要输出到控制台而不是将由Web浏览器呈现的某个位置,则\\n将在控制台输出中创建换行符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM