Search Results
nl2br (PHP 4, PHP 5, PHP 7, PHP 8) nl2br — Inserts HTML line breaks before all newlines in a string
- Printf
Parameters ¶ format The format string is composed of zero or...
- Vsprintf
Parameters ¶ format The format string is composed of zero or...
- Vfprintf
Parameters ¶ stream format The format string is composed of...
- Bin2hex
Convert binary data into hexadecimal representation
- Htmlspecialchars
Certain characters have special significance in HTML, and...
- Substr
Parameters ¶ string The input string. offset If offset is...
- Strtoupper
Returns string with all ASCII alphabetic characters...
- Ucfirst
Make a string's first character uppercase
- Printf
The PHP nl2br() function inserts HTML line breaks before all newlines in a string, making it easier to display text with proper formatting.
Jul 11, 2025 · The nl2br () is an inbuilt function in PHP and is used to insert HTML break tags in the place of all new lines in a string. In normal text editors, the new line is generally denoted by using any of the following.
PHP nl2br () Function Topic: PHP String Reference Prev | Next Description The nl2br() function inserts HTML line breaks before all newlines (\r\n, \n\r, \n and \r) in a string. The following table summarizes the technical details of this function.
- Returns the modified string.
- PHP 4+
The PHP String nl2br () function is used to replace all new lines in a string with HTML break tags. Any of the following is typically used in standard text editors to indicate the new line.
Jan 13, 2026 · The real job of nl2br() and why it still matters I think about nl2br() as a tiny adapter between text and HTML. Plain text uses newline characters for line breaks, while HTML ignores them unless you wrap text in tags that preserve whitespace. nl2br() bridges that gap by inserting tags wherever it sees newline sequences in a string. This is important for real-world workflows: comments, support ...
People also ask
What does nl2br do in PHP?
How does nl2br work?
Why does nl2br run twice?
How to detect double breaks in nl2br?
Learn how to use PHP's nl2br () function to effortlessly convert newlines into HTML line breaks for cleaner and more readable text formatting in your web applications.
