[support] PHP 5.3 upgrade problems
Earnie Boyd
earnie at users.sourceforge.net
Thu Oct 15 12:35:55 UTC 2009
Quoting andy baxter <andy at earthsong.free-online.co.uk>:
>
> I have seen it suggested just to remove the & in cases where the
> function is expecting an object. Does this make sense in PHP terms?
>
Unless the function is defined incorrectly and doesn't use the purpose
of pass by reference then it is absolutely incorrect to remove the &
from the parameter. A pass by reference parameter allows changes to
the external data. If you remove & then the changes become local to
the function and the resultant change is not seen externally.
<?php
$a = 1;
$b = 2;
function c(&$c) {
$c = $c * 2;
}
c($a);
c($b);
print $a . "\n";
print $b . "\n";
?>
Result:
2
4
<?php
$a = 1;
$b = 2;
function c($c) {
$c = $c * 2;
}
c($a);
c($b);
print $a . "\n";
print $b . "\n";
?>
Result:
1
2
--
Earnie
-- http://r-feed.com/ -- http://for-my-kids.com/
-- http://www.4offer.biz/ -- http://give-me-an-offer.com/
More information about the support
mailing list