How to use nl2br in PHP

In this article I will explain how the nl2br() function can be used in PHP.
  • 1623

nl2br() function in PHP

The nl2br() function is used to add HTML line breaks (<br />) in front of all newline (\n) in a string.

Syntax

nl2br(string)

Parameter

  • string string is required parameter. It determine check to string.

Example

The following example show to how the nl2br() function can be used in PHP.

<html>

<body>

<h3 style="color: green;">nl2br() function example in PHP</h3>

    <?php

    echo nl2br("Welcome to.\nC-sharpcorner.");

    ?>

</body>

</html>

 

Output

nl2br-php.gif
You may also want to read these related articles here
 
Ask Your Question 
 
Got a programming related question? You may want to post your question here
 

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.