php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39059 str_replace: fourth parameter is always zero
Submitted: 2006-10-06 10:46 UTC Modified: 2006-10-07 09:38 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: dirk dot thomas at 4wdmedia dot de Assigned:
Status: Closed Package: Strings related
PHP Version: 5CVS-2006-10-06 (snap) OS: Windows XP SP2
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dirk dot thomas at 4wdmedia dot de
New email:
PHP Version: OS:

 

 [2006-10-06 10:46 UTC] dirk dot thomas at 4wdmedia dot de
Description:
------------
Hello,

first: i am using the latest Win32-binary currently available from snaps.php.net (php5.2-win32-200610051830) with an Apache 2.2 (sapi).

When calling the function str_replace the fourth parameter - which should be set to the number of replacements - is always set to zero.

With Php5.1.1 and an Apache 2.0.55 it works as expected.

Best regards,
Dirk

Reproduce code:
---------------
$c = 23;
echo str_replace('i', 'o', 'string', $c);
echo ' '.$c;


Expected result:
----------------
strong 1

Actual result:
--------------
strong 0

Even one string replacement took place ('i' => 'o'), the referenced value for counting is set to zero.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-06 11:04 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip


 [2006-10-06 12:32 UTC] third-chance at gmx dot de
I have tried it with the version from your link.
The problem persists and is still the same.
 [2006-10-06 12:44 UTC] tony2001@php.net
Please make sure you deleted php5ts.dll from 5.1.6 and put the one from the snapshot instead.
I cannot reproduce it with the snapshot.
 [2006-10-06 14:22 UTC] third-chance at gmx dot de
I do not have any old version of php5ts.dll anywhere. Just the current on in the php-directory.
 [2006-10-06 15:20 UTC] edink@php.net
Just tried php-5.2.0RC5 and it works as expected.
 [2006-10-06 16:08 UTC] third-chance at gmx dot de
I tried again using the cli in a fresh directory. The problem is still their.
I also tried with an older snapshot from my disc (php5.2-win32-200608171030): just the same.

When using for example the release 5.1.6 everything works fine.

Are their anywhere older snapshots to norrow down the timewindow? Perhaps i could find the point between to snaps, where it stops working on my computer?

PS: i encouter the same problem with the latest 6.0-snap
 [2006-10-06 17:26 UTC] third-chance at gmx dot de
A friend of mine testet the latest snap on his computer and encoutered the same bug.
He also uses WinXP SP2 and called the cli of php for the test.
 [2006-10-07 09:15 UTC] dirk dot thomas at 4wdmedia dot de
I have testet the example-script with the updated snapshot. Now it works as expected!

So it looks like that this bug has been fixed between the two snaps:
php5.2-win32-200610051830.zip
and 
php5.2-win32-200610070230.zip

I could not test the php6-version, because their are no current win32-builds available (last is 20060924).

Thank you
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 05:01:29 2024 UTC