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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 14:01:30 2024 UTC