php nl2br() function


  Translation results:

UK [n'ju:laɪn] US [n'ju:laɪn]

New line, line feed (no paper feeding)

php nl2br() functionsyntax

Function:Insert a newline character before a new line (\n) in the string

Syntax: nl2br(string,xhtml)

Parameters:

ParametersDescription
stringmust. Specifies the string to check.
xhtml Optional. Boolean indicating whether to use XHTML-compatible line breaks: TRUE - Default. INSERT <br />FALSE - Insert <br>

Description: on each new line (\n) in the string Insert an HTML line break (<br> or <br />) before.

php nl2br() functionexample

<?php
echo nl2br("First line.\nSecond line.",false);
?>

Run instance»

Click the "Run instance" button to view the online instance

Output:

First line.
Second line.

Home

Videos

Q&A