You are currently viewing How to Insert Line break in PHP Echo with Example
  • Post category:PHP

How to Insert Line break in PHP Echo with Example

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:

  1. In the above code, we have printed “Hello world” using an echo statement.
  2. To move the cursor to next line, you can use HTML <br/> tag.
  3. 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.

Leave a Reply