30-day PHP learning record (line break)

烟雨青岚
Release: 2023-04-09 08:30:02
forward
2663 people have browsed it

30-day PHP learning record (line break)

PHP newline character

I originally thought that using double quotes could escape \n or
Perform a newline operation and find

\nUsage

The following code

<?php
    echo "nocs\n";    echo "you";?>
Copy after login

Online editing The output result of the processor shows

nocs
you
Copy after login
Copy after login

The output result of the webpage shows

nocs you
Copy after login

It can be seen that the webpage display does not have a line break effect, it is only displayed as a space
Conclusion:\nLine breaks are only applicable to command line execution

##
Usage

The following code

<?php
    echo "nocs<br>";    echo "you";?>
Copy after login

Online editor Display results


nocs<br>you
Copy after login

Web page display results

nocs
you
Copy after login
Copy after login
You can find that the web page display
achieves the line wrapping effect

Conclusion
Web page display line breaks can be realized

Notes

Found a phenomenon when using double quotes to escape the \n character. The web page display does not realize line wrapping, but when viewing the web page source code, the line wrapping effect is achieved

When using double quotes to escape
, although the web page displays a line wrapping result, when viewing the web page source code label
is still displayed Come out
This means that the result of viewing the source code of the web page is consistent with the result displayed by compiling PHP from the command line

Thank you for reading, I hope you will benefit a lot.

Recommended tutorial: "

php tutorial"

The above is the detailed content of 30-day PHP learning record (line break). 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