|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-06-12 00:01 UTC] gregory dot szorc at case dot edu
Description: ------------ A method is called on an instance of a class which is derived from a chain of derived classes, some abstract. The method is defined in the base class and this method alters a variable also defined in the base class. When the method is called, the object is unchanged. During debugging, the variable is actually changed by the base method. However, this change of variable is not propogated down into the derived classes. When the base method is changed so that it changes another variable in the base class, the changes are reflected after the method is called. In summary, a function call does not produce an obvious change of variable. When the function is changed so it alters another variable on top of the original, both changes are seen after the function call. Reproduce code: --------------- I have been unable to reproduce this code outside of the project in which I discovered the bug. To obtain the code, use subversion: `svn co -r 119 http://zorro.case.edu/svn/repos/php_classes/File_iCal/trunk/ iCal` Use might need to add the created directory to the PHP include path for the code to run. Read File/iCal/BaseComponent.php at line 234 for info on how to reproduce. Expected result: ---------------- A variable gets changed via function call. Actual result: -------------- The variable appears left unchanged unless the function definition itself is changed so that the object is further modified. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 25 11:00:01 2025 UTC |
class.php: <? class Test { var $Dynamic = Array(); function Start() { $Dynamic = Array("test"=>"hope") $this->$Dynamic = $Dynamic; } function GetArray() { return $this->Dynamic; } } ?> test.php: <? require class.php; $file = new Test(); $file->Start(); print_r($file->Dynamic); // Will result in 'Array()' $s = $file->GetArray(); // Will result in 'Fatal error: Cannot access empty property' print_r($s) ?>