It's ok,
I discovered that object (if not passed by reference explicitly) is first
duplicated (internally) and only then the method is called.
Proof code:
<?php
class myCls
{
var $myVar;
function myCls() { $this->myVar = 1; }
function myInc() { $this->myVar++; }
function myEcho() { echo "$this->myVar "; }
}
$myObj = new myCls();
$myObj->myEcho();
$myObj->myInc();
$myObj->myEcho();
call_user_func(array($myObj, 'myInc'));
$myObj->myEcho();
unset($myObj);
echo "\n";
$myObj = new myCls();
$myObj->myEcho();
$myObj->myInc();
$myObj->myEcho();
call_user_func(array(&$myObj, 'myInc'));
$myObj->myEcho();
?>
produces output:
1 2 2
1 2 3
On Wednesday 15 December 2004 08:28, Bostjan Skufca @ domenca.com wrote:
> Hi all,
>
> is there any internal difference between following calls (they occur inside
> some class)?
>
> #1 register_shutdown_function(array($this, 'myfunc'));
> #2 register_shutdown_function(array(&$this, 'myfunc'));
> (note the reference operator in #2)
>
> Or is parameter "$this" in example #1 forced to be taken as reference
> internally, which makes both calls basically identical?
>
>
> Thank you for your kind response.
>
>
> Best regards,
> Bostjan Skufca
--
Best regards,
Bostjan Skufca
system administrator
Domenca d.o.o.
Phone: +386 4 5835444
Fax: +386 4 5831999
http://www.domenca.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php