ID: 22141
Updated by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
Status: Closed
Bug Type: Scripting Engine problem
Operating System: Mac OS 10.2
PHP Version: 4.2.3
New Comment:
One more thing. It actually hadn't been removed in the 4.3 branch
until just now as the method was not known to cause any actual problems
and non-bug-fix changes are generally kept to the development branch.
I've gone ahead and merged in the relevant portion of the changes to
str_replace. PHP will now throw the customary "Incorrect Parameter
Count" error if you use anything but 3 parameters with str_replace.
Previous Comments:
------------------------------------------------------------------------
[2003-02-10 00:50:22] [EMAIL PROTECTED]
This has already been fixed in CVS. PHP's internals contain two
str_replace methods, the fourth parameter (when set to a non-zero
value) uses the alternate search and replace method.
It's not documented because the alternate method was not endoresed for
use. As of 4.3.1 (which is yet to be released, you can use a snapshot
from snaps.php.net in the mean time), the alternate method has been
removed (and the existing method improved for speed and efficiency.
------------------------------------------------------------------------
[2003-02-09 15:15:34] [EMAIL PROTECTED]
I was inadvertently including a fourth argument of "-1"
with some instances of str_replace() -- since I got into
the habit of the limit arg using preg_replace() -- and I
noticed an odd behavior:
str_replace("-embed-a-", "hey", "-embed-a-", -1) returns
"hey," as expected.
str_replace("-embed-a-", "hey", "-embed-b-", -1) returns
"embed-b-," as expected.
But str_replace("-embed-a-", "hey", "-embed-aa-", -1) hangs
the script until the max execution time.
Removing the extraneous argument made my script work
properly, but I would expect PHP to either ignore the extra
argument, or return an error, rather than hanging up
completely.
-Arlo
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=22141&edit=1