Home > Backend Development > PHP Tutorial > The difference between the characters '\n' and '
' in php

The difference between the characters '\n' and '
' in php

王林
Release: 2023-04-07 20:20:02
forward
4420 people have browsed it

The difference between the characters '\n' and '<br />' in php

When writing PHP script code, we often see the two characters \n and
. They both have the function of breaking lines, so what exactly do they mean? What's the difference?

1.\n is to make the source code wrap, but the content displayed by the browser is not;

2.
is to make The content displayed by the browser wraps, but the source code does not.

Example:

PHP code 1:

<?php
echo 0;
echo "\n";
echo 1;
?>
Copy after login

Browser display:

The difference between the characters \n and <br /> in php

##No newline

View source code:

The difference between the characters \n and <br /> in php

With line breaks


PHP code 2:

<?php
echo 0;
echo "<br />";
echo 1;
?>
Copy after login
Browser display:


The difference between the characters \n and <br /> in php

With line breaks

View source code:

The difference between the characters \n and <br /> in php

Without line breaks

This is the difference between the two.

Recommended tutorial:

php tutorial

The above is the detailed content of The difference between the characters 'n' and '
' in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template