php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #1311 str_replace() produces corrupt result
Submitted: 1999-04-10 17:55 UTC Modified: 1999-04-10 18:26 UTC
From: colin at whistler dot net Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 3.0.6 OS: SunOS 5.5.1 (Intel)
Private report: No CVE-ID: None
 [1999-04-10 17:55 UTC] colin at whistler dot net
This script demonstrates the problem:

$haystack = "Line 1<BR>Line 2<BR>Line 3";
$result = str_replace("<BR>","\n",$haystack);
echo($result);

The output of this script is:

Line 1
Line 2

This is followed by about 65K of what appears to be random sections of memory as it contains swaths of unparsed PHP code and PHP-generated HTML from other scripts.

PHP is compiled as an Apache module.

I've also tested this script with PHP 3.0.7, compiled as CGI under Linux, with no problems. 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-04-10 18:26 UTC] jim
This was partially fixed in 3.0.7 and completely fixed in 3.0.8.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 15 23:00:01 2026 UTC