Re: call_user_method object not by reference

From: Date: Sat, 14 Oct 2000 19:54:45 +0000
Subject: Re: call_user_method object not by reference
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-20164@lists.php.net to get a copy of this message
Mike Heath wrote: > > 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? Hi, Not only that, you can't pass params by reference to the function. So, yes, AFAICT call_user_method is entirely pointless. Better off just using $var->$method($param) instead of call_user_method($method, $var, $param); Ciao, Andreas Pour http://www.kde.com/ : Everything KDE http://apps.kde.com/: The Latest in KDE Applications

« previous php.general (#20164) next »