The nl2br() function inserts HTML line breaks (<br> or <br />) in front of each newline ( ) in a string. Syntax. nl2br(string,xhtml).