Home >Backend Development >PHP Tutorial >How to wrap echo in php
In PHP, the methods to implement echo line wrapping are: echo "" tag: line wrapping in the browser. echo "\n": Newline in a text file or command line. Use the PHP_EOL constant: Automatically detect and use operating system newlines.
The echo method to implement line breaks in PHP
In PHP, echo is a method used in the output buffer A language construct for printing values in . To achieve line breaks, you can use the following method:
echo "
"
## tag represents a line break in HTML . Use this to display a new line in the browser.
Example:
<code class="php"><?php echo "Hello"; echo "<br>"; echo "World!"; ?></code>
Output:
<code>Hello World!</code>
echo "\n"
\n is a newline character that creates a new line in a text file or command line.
Example:
<code class="php"><?php echo "Hello"; echo "\n"; echo "World!"; ?></code>
Output:
<code>Hello World!</code>
Note:
to achieve line breaks in the browser, and
echo "\n" to implement line breaks in text files or command lines.
The above is the detailed content of How to wrap echo in php. For more information, please follow other related articles on the PHP Chinese website!