|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28048 using str_replace() together with while chaches PHP
Submitted: 2004-04-18 16:12 UTC Modified: 2004-04-18 16:45 UTC
From: johan at braattha dot se Assigned:
Status: Not a bug Package: Reproducible crash
PHP Version: 4.3.4 OS: windows2000
Private report: No CVE-ID: None
 [2004-04-18 16:12 UTC] johan at braattha dot se
When using str_replace() in a way it might not be thought (inside a while-loop where the statement is the actual str_replace one...) for (but still a valid one) it crashes php. This is 4 lines of code...

It just takes a while (less than a minute for me) before php actually crashes. I have not seen any updates on this bug in 4.3.5 or 4.3.6...

Reproduce code:
$string="I     hate    double      spaces.";
while ($string=str_replace("  "," ",$string)) {
$string=str_replace("  "," ",$string);

Expected result:
I expected $string to be: "I hate double spaces." I did not realise that str_replace() did this without the while loop... So everything works like a charm for me, but it might be problematic for other people?

Actual result:
A chrash... it takes a while and then apache restarts...


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-04-18 16:45 UTC]
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.

Try 4.3.6 first.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Feb 19 22:01:28 2020 UTC