[PHP-DEV] Bug #11448: str_replace From: a2zofciv2 <email protected>
Date: 06/12/01

From: a2zofciv2 <email protected>
Operating system: cobalt linux
PHP version: 4.0.5
PHP Bug Type: Unknown/Other Function
Bug description: str_replace

the following line:

$line = str_replace("pattern", Pattern(),$line);

where Pattern() is a function that returns a string.

Pattern executes everytime this code line is encountered, even if "pattern" is not a match on $line.

so if i loop through a file running that line, the function Pattern() will execute every single time, match or no match.

(my) common sense says this function should only execute when a match is found. Is this a bug? I didn't know about it and something like this could seriously affect performance of a program.

Also I don't think the modules or any other of your requirements are relevant for this issue.

-- 
Edit Bug report at: http://bugs.php.net/?id=11448&edit=1

-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>