Line break in PHP echo
In this article, we will see how to insert a line break in PHP echo statement. You can use ‘/n’ to insert a line break. But here we see the break tag in HTML.
Line Break
- To add a line break we can use an HTML <br/> tag within a string.
- HTML br tag moves the cursor to the next line so that from there on next content can be placed or written.
Example code
<?php
echo "Hello world <br/> Hello world <br/>";
echo "Hello world <br/>";
echo "Hello world <br/>";
echo "Hello world ";
echo "<br/> Hello world ";
echo "Hello world ";
echo "<br/>";
echo "Hello world ";
echo "<br/>";
?>
Output
Hello world
Hello world
Hello world
Hello world
Hello world
Hello world
Hello world
Hello world
Steps:
- In the above code, we have printed “Hello world” using an echo statement.
- To move the cursor to next line, you can use HTML <br/> tag.
- In many different ways to push the content to the next line. You can use two <br/> at a time, it creates one line space.