php.net |  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
Description:
------------
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 />

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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

\r\n is a single Windows style linebreak. \n\r are two linebreaks
(Unix style + old MacOS style).
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Dec 13 21:01:24 2019 UTC