nl2br

PHP 4, PHP 5, PHP 7, PHP 8
nl2br - Inserts HTML line breaks before all newlines in a string
Nl2br Online Tool
Manual
Code Examples

Example #1 Using nl2br

Result: foo isn't<br /> bar
PHP Version:

Example #2 Generating valid HTML markup using the <span class='function-parameter'>use_xhtml</span> parameter

Result: Welcome<br> This is my HTML document
PHP Version:

Example #3 Various newline separators

Result: This<br /> is<br /> a<br /> string<br />
PHP Version:


Example #4 of nl2br

PHP Version:


Function nl2br:

Strings Functions

Most used PHP functions