php Newlines vs html break

Gre*_*ett 1 php

这段代码:

<?php
  echo "This is the first line. \n";
  echo "This is the second line.";
?>
Run Code Online (Sandbox Code Playgroud)

在同一行回显所有:("这是第一行.这是第二行.")不应该\n有基本相同的功能<br>吗?我在这里错过了什么?

Set*_*ine 5

html不渲染\n,\n将在你的html源代码中放置一个中断

PHP

<?php
echo "<p>This is the first line. \n";
echo "This is the second line.</p>";
?>
Run Code Online (Sandbox Code Playgroud)

HTML源码

<p> This is the first line.
This is the second line.</p>
Run Code Online (Sandbox Code Playgroud)

HTML

This is the first line. This is the second line.
Run Code Online (Sandbox Code Playgroud)

PHP

<?php
echo "<p>This is the first line.";
echo "This is the second line.</p>";
?>
Run Code Online (Sandbox Code Playgroud)

HTML源码

<p> This is the first line.This is the second line.</p>
Run Code Online (Sandbox Code Playgroud)

HTML

This is the first line.This is the second line.
Run Code Online (Sandbox Code Playgroud)

PHP

<?php
echo "<p>This is the first line. <br/>";
echo "This is the second line.</p>";
?>
Run Code Online (Sandbox Code Playgroud)

HTML源码

<p> This is the first line.<br/>This is the second line.</p>
Run Code Online (Sandbox Code Playgroud)

HTML

This is the first line. 
This is the second line.
Run Code Online (Sandbox Code Playgroud)