php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23268 str_replace total system overload
Submitted: 2003-04-18 06:31 UTC Modified: 2003-04-23 00:21 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: nick at netdupe dot com Assigned:
Status: No Feedback Package: Performance problem
PHP Version: 4.3.1 OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: nick at netdupe dot com
New email:
PHP Version: OS:

 

 [2003-04-18 06:31 UTC] nick at netdupe dot com
If you accidently put something like the following in 
str_replace the server goes nuts and does not return 
any information.

<?
$code = "hello";
$string = "Hello, Bob how are you";
$text = str_replace("$code", "hey", $string);
?>

This only occurs when you put $code in quotation marks. 
Shouldnt it come up? I did this the server load went 
from 0.05 to 23.4

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-04-18 06:33 UTC] nick at netdupe dot com
got a little mistake in there, "shoudnt it come up?" 
should be "shoudnt it come up with an error?"
 [2003-04-18 09:40 UTC] magnus@php.net
I could not reproduce it with exactly that code. 
Tried both 4.3.0 and current PHP_4_3 branch. 
 [2003-04-18 17:07 UTC] nick at netdupe dot com
ok this is the code i used it with:
<?
$file = file("smillies.db");
      foreach($file as $value){
           list($rand,$code,$image) = explode("|<|", 
$value);
           $code = stripslashes($code);
           $fusnewsm = str_replace("$code","<img 
src=\"http://images.devdino.com/smillies/$image\" 
border=\"0\">",$fusnewsm );
      }
?>
You will need smilies.db you can get it from
www.devdino.com/smillies.db.
 [2003-04-18 17:21 UTC] pollita@php.net
Significant portions of the str_replace function are rewritten in the development branch.  Can you try downloading a snapshot of PHP-5.0-dev and seeing if the problem persists?  I'd also like to ask you to try the latest snapshot of the stable branch. PHP-4.3-stable

http://snaps.php.net

And incidently your first example shouldn't come up with any error, it should simply fail to replace anything (str_replace is case-sensitive)
 [2003-04-23 00:21 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 20:01:29 2024 UTC