Forum Moderators: coopster
Warning: Call-time pass-by-reference has been deprecated - argument passed by value
Yet according to all the documentation I have seen on PHP 5, in future all functions will be called by ref rather than by value, implying it hasn't be deprecated, and is perfectly ok to use.
Anyone know anything on this?
Cheers,
asp
I'm actually trying to call a 3rd party COM object with it. But looking up that setting in php.ini I see:
; Whether to enable the ability to force arguments to be passed by reference
; at function call time. This method is deprecated and is likely to be
; unsupported in future versions of PHP/Zend. The encouraged method of
; specifying which arguments should be passed by reference is in the function
; declaration. You're encouraged to try and turn this option Off and make
; sure your scripts work properly with it in order to ensure they will work
; with future versions of the language (you will receive a warning each time
; you use this feature, and the argument will be passed by value instead of by
; reference).
So thanks for that - at least now I know why!
Cheers,
asp
<?
function myfunc($id) {
$id="Hello";
}
myfunc(&$myvar);
?>
That is decricated. You should redefine to this:
<?
function myfunc(&$id) {
$id="Hello";
}
myfunc($myvar);
?>
Small but significant difference. The first (your problem) passes variable by reference at runtime. The second (the fix) defines the function saying the variable will be passed by reference (at compile time).
This should solve your problem.
daisho.