[Tickets #3957] call_user_func always passes copy of Turba object to _turba_hook_encode_{attribute}
bugs@bugs.horde.org
bugs at bugs.horde.org
Mon May 22 00:07:38 PDT 2006
DO NOT REPLY TO THIS MESSAGE. THIS EMAIL ADDRESS IS NOT MONITORED.
Ticket URL: http://bugs.horde.org/ticket/?id=3957
-----------------------------------------------------------------------
Ticket | 3957
Updated By | avo at trustsec.de
Summary | call_user_func always passes copy of Turba object to _turba_hook_encode_{attribute}
Queue | Turba
Version | 2.1.1
State | Feedback
Priority | 2. Medium
Type | Bug
Owners | Horde Developers
-----------------------------------------------------------------------
avo at trustsec.de (2006-05-22 00:07) wrote:
> True, but it's also useful to be able to modify the object, and part of
the reason the $this
> parameter was added. Can you test with using &$this instead of $this with
the call_user_func
> syntax?
That works, but you'll always get a reference. Here's an example:
function foo($x)
{
$x = 42;
}
function bar(&$x)
{
$x = 43;
}
$y = 0;
call_user_func('foo', &$y);
print "$y\n"; # -> 42
call_user_func('bar', &$y);
print "$y\n"; # -> 43
If the function is called directly you can decide in the hook function
whether you'd like to get a reference or a copy:
function foo($x)
{
$x = 42;
}
function bar(&$x)
{
$x = 43;
}
$y = 0;
foo($y);
print "$y\n"; # -> 0
bar($y);
print "$y\n"; # -> 43
I don't know what's more sensible in this case.
More information about the bugs
mailing list