Thursday, October 23, 2025
HomeLanguagesHow to create a New Line in PHP ?

How to create a New Line in PHP ?

New Line helps the page to look better and presentable. We will learn to insert a new line in PHP using 2 ways.

  • Using Line Breaks as in HTML
  • Using New Line tags

Using Line Breaks as in HTML: The <br> tag in HTML is used to give the single line break. It is an empty tag, so it does not contain an end tag.

Syntax:

</br>

Example: 

PHP




<?php
echo "Akshit ". "<br>". "Loves GeeksForGeeks";
?>


Output

Akshit 
Loves GeeksForGeeks

Using new line tags: Newline characters \n or \r\n can be used to create a new line inside the source code.

Syntax: 

 "\n"

Example 1: 

PHP




<?php
echo "Akshit " ."\n"."Loves GeeksForGeeks";
?>


Output

Akshit 
Loves GeeksForGeeks

Syntax: 

"\r\n"

Example 2: 

PHP




<?php
echo "Akshit " ."\r\n"."Loves GeeksForGeeks";
?>


Output

Akshit 
Loves GeeksForGeeks
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS