Bug #11800 Updated: call_user_method() bug (it won't change properties)

From: Date: Sun, 21 Oct 2001 23:38:29 +0000
Subject: Bug #11800 Updated: call_user_method() bug (it won't change properties)
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-68657@lists.php.net to get a copy of this message
ID: 11800 Updated by: sniper Reported By: bachi2@insign.ch Status: Closed Bug Type: Class/Object related Operating System: Linux PHP Version: 4.0.6 New Comment: call_user_method("increase", &$t); works too with PHP 4.1.0RC1 but this function is deprecated. Previous Comments: ------------------------------------------------------------------------ [2001-10-21 19:36:52] sniper@php.net This is fixed in CVS. You just have to use: call_user_func(array(&$t, "increase")); instead though. --Jani ------------------------------------------------------------------------ [2001-06-29 09:02:13] bachi2@insign.ch I've run into this already a year ago and now again: The call_user_method() function does not correctly change the properties of the object it's called upon - OR (what I assume) it copies the called object. Just try the code below - the counter remains on 4, not 6 as supposed. (I also tried to pass the obj. by reference: call_user_method ("increase", &$t); - it didn't help) class test { var $a=0; function increase() { $this->a++; echo "a is now: ".$this->a."\n "; } } $t = new test(); echo "Direct calls:\n "; $t->increase(); $t->increase(); $t->increase(); echo " \n\nIndirect calls:\n "; call_user_method ("increase", $t); call_user_method ("increase", $t); call_user_method ("increase", $t); ------------------------------------------------------------------------ Edit this bug report at http://bugs.php.net/?id=11800&edit=1

« previous php.dev (#68657) next »