#23788 [NEW]: *_replace() clobbers referenced array elements
| From: | moriyoshi@php.net | Date: | Sat, 24 May 2003 06:06:16 +0000 |
| Subject: | #23788 [NEW]: *_replace() clobbers referenced array elements | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-40331@lists.php.net to get a copy of this message | ||
From: moriyoshi@php.net
Operating system: any
PHP version: 4.3.2RC4
PHP Bug Type: Strings related
Bug description: *_replace() clobbers referenced array elements
Here's a simple test case.
--TEST--
--FILE--
<?php
$numeric = 123;
$bool = true;
$foo = array(&$numeric, &$bool);
var_dump($foo);
str_replace("abc", "def", $foo);
var_dump($foo);
?>
--EXPECT--
array(2) {
[0]=>
&int(123)
[1]=>
&bool(true)
}
array(2) {
[0]=>
&int(123)
[1]=>
&bool(true)
}
While the actual output is
array(2) {
[0]=>
&int(123)
[1]=>
&bool(true)
}
array(2) {
[0]=>
&string(3) "123"
[1]=>
&string(1) "1"
}
IMO this is not the intended behaviour, but also looks like a WFX issue.
Note that the same applies to preg_replace() / ereg_replace().
--
Edit bug report at http://bugs.php.net/?id=23788&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=23788&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=23788&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=23788&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=23788&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=23788&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=23788&r=support
Expected behavior: http://bugs.php.net/fix.php?id=23788&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=23788&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=23788&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=23788&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=23788&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=23788&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=23788&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=23788&r=gnused