|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2014-10-16 09:41 UTC] bwoebi@php.net
-Status: Open
+Status: Not a bug
[2014-10-16 09:41 UTC] bwoebi@php.net
[2014-10-16 09:45 UTC] guoxuivy at gmail dot com
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 18:00:01 2025 UTC |
Description: ------------ class a{ public $s = array('a' => 'a%se'); function aa(){ foreach(range(1,5) as $v){ $this->s['a'] = str_replace('%s', $v, $this->s['a']); var_dump($this->s); } } } $a = new a(); $a->aa(); result always: array(1) { ["a"]=> string(3) "a1e" } array(1) { ["a"]=> string(3) "a1e" } array(1) { ["a"]=> string(3) "a1e" } array(1) { ["a"]=> string(3) "a1e" } array(1) { ["a"]=> string(3) "a1e" } i think right: array(1) { ["a"]=> string(3) "a1e" } array(1) { ["a"]=> string(3) "a2e" } array(1) { ["a"]=> string(3) "a3e" } array(1) { ["a"]=> string(3) "a4e" } array(1) { ["a"]=> string(3) "a5e" } Test script: --------------- class a{ public $s = array('a' => 'a%se'); function aa(){ foreach(range(1,5) as $v){ $this->s['a'] = str_replace('%s', $v, $this->s['a']); var_dump($this->s); } } } $a = new a(); $a->aa(); result always: array(1) { ["a"]=> string(3) "a1e" } array(1) { ["a"]=> string(3) "a1e" } array(1) { ["a"]=> string(3) "a1e" } array(1) { ["a"]=> string(3) "a1e" } array(1) { ["a"]=> string(3) "a1e" } i think right: array(1) { ["a"]=> string(3) "a1e" } array(1) { ["a"]=> string(3) "a2e" } array(1) { ["a"]=> string(3) "a3e" } array(1) { ["a"]=> string(3) "a4e" } array(1) { ["a"]=> string(3) "a5e" } Expected result: ---------------- class a{ public $s = array('a' => 'a%se'); function aa(){ foreach(range(1,5) as $v){ $this->s['a'] = str_replace('%s', $v, $this->s['a']); var_dump($this->s); } } } $a = new a(); $a->aa(); result always: array(1) { ["a"]=> string(3) "a1e" } array(1) { ["a"]=> string(3) "a1e" } array(1) { ["a"]=> string(3) "a1e" } array(1) { ["a"]=> string(3) "a1e" } array(1) { ["a"]=> string(3) "a1e" } i think right: array(1) { ["a"]=> string(3) "a1e" } array(1) { ["a"]=> string(3) "a2e" } array(1) { ["a"]=> string(3) "a3e" } array(1) { ["a"]=> string(3) "a4e" } array(1) { ["a"]=> string(3) "a5e" } Actual result: -------------- class a{ public $s = array('a' => 'a%se'); function aa(){ foreach(range(1,5) as $v){ $this->s['a'] = str_replace('%s', $v, $this->s['a']); var_dump($this->s); } } } $a = new a(); $a->aa(); result always: array(1) { ["a"]=> string(3) "a1e" } array(1) { ["a"]=> string(3) "a1e" } array(1) { ["a"]=> string(3) "a1e" } array(1) { ["a"]=> string(3) "a1e" } array(1) { ["a"]=> string(3) "a1e" } i think right: array(1) { ["a"]=> string(3) "a1e" } array(1) { ["a"]=> string(3) "a2e" } array(1) { ["a"]=> string(3) "a3e" } array(1) { ["a"]=> string(3) "a4e" } array(1) { ["a"]=> string(3) "a5e" }