Bug #11448 Updated: str_replace
| From: | rasmus@php.net | Date: | Tue, 19 Jun 2001 03:37:53 +0000 |
| Subject: | Bug #11448 Updated: str_replace | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-57096@lists.php.net to get a copy of this message | ||
ID: 11448
Updated by: rasmus
Reported By: a2zofciv2@hotmail.com
Old-Status: Bogus
Status: Closed
Bug Type: Unknown/Other Function
Operating system:
PHP Version: 4.0.5
Assigned To:
Comments:
Uh, Jani, of course you can use a function there.
But the function will get evaluated to produce a string
which becomes the argument to str_replace(). That's just the way it works. The function will
be called every time.
If you don't want it called, add the appropriate logic to
not call it by checking for the match first with a strstr()
call.
Previous Comments:
---------------------------------------------------------------------------
[2001-06-13 10:57:59] sniper@php.net
Where does it say you can use function as the replacement?
You have to set it to variable first.
---------------------------------------------------------------------------
[2001-06-12 19:07:10] a2zofciv2@hotmail.com
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.
---------------------------------------------------------------------------
ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at http://bugs.php.net/?id=11448&edit=2