PHP nl2br() Function

The nl2br() function in PHP inserts HTML line breaks before all newlines in a string.

Syntax

Parameter

sting(required)- This parameter specifies the input string.

is_xhtml(optional)- This parameter states whether to use XHTML compatible line breaks or not.. The default value is true.

Return

This function returns the altered string with <br /> or <br> inserted before all newlines (\r\n, \n\r, \n and \r).

Example 1

Output

Example 2

Output

Example 3

Output

Pin It on Pinterest

Share This