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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: justcoding at outlook dot com
New email:
PHP Version: OS:

 

 [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 05:01:26 2019 UTC