php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36560 [chm] bug on function.str-replace.html
Submitted: 2006-02-28 16:50 UTC Modified: 2006-02-28 18:07 UTC
From: gruja at phy dot bg dot ac dot yu Assigned:
Status: Not a bug Package: Strings related
PHP Version: 5.1.2 OS: windows
Private report: No CVE-ID: None
 [2006-02-28 16:50 UTC] gruja at phy dot bg dot ac dot yu
Description:
------------
I have found a bug on page function.str-replace.html
[chm date: 2005-05-20]...

When I wish to replace new line character it does insert instead.


Reproduce code:
---------------
$string="aaa
bbb";
$string=str_replace("\n", "<br>", $string);
print $string;

Expected result:
----------------
aaa<br>bbb

Actual result:
--------------
aaa
<br>bbb

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-02-28 17:03 UTC] bjori@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

Windows uses \r\n not \n
 [2006-02-28 18:07 UTC] gruja at phy dot bg dot ac dot yu
I have tested similar code on bouth windows and unix. Production server is unix, and I use windows machine for developing applications. I have seen this bug first time on unix, and then again at my PC. 
Actualy I read string from MySQL, then try to remove \n (beacose it shold be all writen in one line for javascript) and to replace it with <br>...
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC