call_user_method object not by reference

From: Date: Sat, 14 Oct 2000 19:38:49 +0000
Subject: call_user_method object not by reference
Groups: php.general 
Request: Send a blank email to php-general+get-20163@lists.php.net to get a copy of this message
The PHP 4 function call_user_method does not use a reference to the object (or am I doing something wrong here.) <?php class foo { var $num; function foo() { $this->num = 0; } function addcount() { $this->num++; echo "<br>".$this->num; } } $joe = new foo(); call_user_method("addcount", $joe); call_user_method("addcount", $joe); call_user_method("addcount", $joe); ?> You would think this would echo "123" but instead it outputs "111". Should call_user_method be using references instead of copying the object? Any comments and/or help would be appreciated. Thanks, Mike

« previous php.general (#20163) next »