Re: cvs: pear /Auth Auth.php
| From: | Yavor Shahpasov | Date: | Tue, 16 Mar 2004 08:59:17 +0000 |
| Subject: | Re: cvs: pear /Auth Auth.php | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-26452@lists.php.net to get a copy of this message | ||
It appears you can avoid this by using @ char instead of &
the below code triggers a warning with php4 when using & and allow_call_time_pass_reference is off. The @ seems to work with php 5 also.
I have checked with PHP 4.3.4 and PHP 5 Beta 4
What do you think ?
Yavor
---- Snip Test code ----
using this code
<?php
function testRef($object){
$object->name = "Changed";
}
$object = new StdClass();
$object->name = "Orig";
print "Before not ref \n";
print "NAME:{$object->name} \n";
call_user_func('testRef', $object);
print "After not ref \n";
print "NAME:{$object->name} \n";
print "----\n";
print "Before ref \n";
print "NAME:{$object->name} \n";
call_user_func('testRef', &$object);
print "After ref \n";
print "NAME:{$object->name} \n";
print "----\n";
print "Before using @ picked up from the comments in the php manual \n";
print "NAME:{$object->name} \n";
call_user_func('testRef', @$object);
print "After using @ \n";
print "NAME:{$object->name} \n";
?>
I get
PHP4
Before not ref
NAME:Orig
After not ref
NAME:Orig
----
Before ref
NAME:Orig
After ref
NAME:Changed
[yavo@odin yavo]$ rm test.php
[yavo@odin yavo]$ rz
rz waiting to receive.Š[yavo@odin yavo]$ php test.php
Before not ref
NAME:Orig
After not ref
NAME:Orig
----
Before ref
NAME:Orig
After ref
NAME:Changed
----
Before using @
NAME:Changed
After using @
NAME:Changed
PHP5
<?php
function testRef($object){
$object->name = "Changed";
}
$object = new StdClass();
$object->name = "Orig";
print "Before not ref \n";
print "NAME:{$object->name} \n";
call_user_func('testRef', $object);
print "After not ref \n";
print "NAME:{$object->name} \n";
print "----\n";
print "Before ref \n";
print "NAME:{$object->name} \n";
call_user_func('testRef', &$object);
print "After ref \n";
print "NAME:{$object->name} \n";
print "----\n";
print "Before using @ picked up from the comments in the php manual \n";
print "NAME:{$object->name} \n";
call_user_func('testRef', @$object);
print "After using @ \n";
print "NAME:{$object->name} \n";
?>
Martin Jansen wrote:
On Tue Mar 16, 2004 at 07:4908AM -0000, Yavor Shahpasov wrote:-- Yavor Shahpasov yavo@siava.orgI haven't double checked that yet, but won't this raise a warning when allow_call_time_pass_reference is set to Off?- call_user_func($this->loginCallback,$this->username, $this); + call_user_func($this->loginCallback,$this->username, &$this);