PHP echo newline
The PHP echo newline technique will use the HTML built-in newline tag, that is, the <br> tag. This newline tag means only one line at a time. If you want to change two lines, you need to use the <br> tag twice. , You can also use paragraph tags, that is, <p> tags to achieve the effect of changing two lines at a time. We will implement the <br> and <p> tags in the example for readers' reference. Through the concept of PHP echo html , you can easily echo newline tags, and all regular mainstream browsers support the effect of PHP echo newline tags.
PHP echo line break example 1. Only change a line <br> tag
echo'<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'; //Web page encoding declaration
echo'This is the first line<br>';
echo 'This is the second line<br>';
echo'<br>';
echo'This is the fourth line';
?>
this is the second row
this is the fourth row
It should be noted here that the echo wrap effect must use single quotes (") or double quotes ("") to wrap the entire string, including the <br> tag, so that PHP can smoothly output the newline tags as a string. The browser can understand it. For the usage of echo, please refer to the detailed introduction of " PHP echo ".
PHP echo line break example 2: Paragraph <p> tag and line break <br> tag
echo'<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'; //Web page encoding declaration
echo'<p>This is the first paragraph<br> This is the second line of the first paragraph</p>';
echo'<p>This is the second paragraph<br>This is the second line of the second paragraph</p>';
?>
This is the first paragraph
This is the second line of the first paragraph
This is the second paragraph,
this is the second line of the second paragraph
The above two examples are commonly used PHP echo line breaks. If you simply want to change a line, then use <br>. If the purpose of line breaking is a paragraph, the <p> tag is more suitable, but this part There is no mandatory requirement, depending on the web designer's own plan.
Post a Comment
0 Comments