|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70320 nl2br() behavior with \n\r
Submitted: 2015-08-21 14:07 UTC Modified: 2015-08-21 14:48 UTC
From: justcoding at outlook dot com Assigned: cmb (profile)
Status: Not a bug Package: Strings related
PHP Version: 7.0.0RC1 OS: Windows 7 64 Bit
Private report: No CVE-ID: None
 [2015-08-21 14:07 UTC] justcoding at outlook dot com
The function nl2br() have a problem with strings, that have a \n\r inside. 
It returns a newline and a HTML line break for that. 

But the behavior of nl2br() with \r\n is different. 
It returns only a HTML line break for that.

Test script:
echo nl2br("This\r\nis\n\ra\nstring\r");

Expected result:
This<br />
is<br />
a<br />
string<br />

Actual result:
This<br />
is<br />

a<br />
string<br />


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-08-21 14:48 UTC]
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2015-08-21 14:48 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

\r\n is a single Windows style linebreak. \n\r are two linebreaks
(Unix style + old MacOS style).
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Jul 16 00:01:27 2024 UTC