|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-07-05 19:07 UTC] none at space dot com
Description:
------------
proper reference documentation missing on how to switch from 'call-time call-by-reference' to 'call-by-reference'.
with more and more ISP's upgrading php from versions prior the deprecated 'call-time call-by-reference' to newer versions, more and more people get utterly frustrated searching solutions to fix their codes or libs for the two situations below.
especially passing 'no object' or null to a class has become critical and there is no clear statement in the documentation of (references explained) on what logic the guys that deprecated the the 'call-time' functionality had in mind to compensate for that lack of functionality.
i think it's about time you post the concept and solution of this change somewhere prominently.
Reproduce code:
---------------
function foo (& $var){
if (is_null($var)){return 0};
return(1);
}
#call now
foo($somevar); #will work
foo(''); #will not work (how to do this properly?)
foo(1); #will not work (obviously)
Expected result:
----------------
>1
>0
>0
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 20 13:00:01 2025 UTC |
I agree totally! We used to be able to do the following: myfunc(& $someobj); #and myfunc(''); #this, if nothing passed function foo ($obj){ if(is_null($obj)){...}; ... } At this point we have to pre-check everything and do some massive recoding! What is an easy solution for this or waht were you thinking when chaning this? How do I pass 'nothing' now?above: sorry, typo: function foo ($obj){ should obviously be function myfunc ($obj){ i was copying...Possible solution: function foo (& $var){ if (is_null($var)){return 0}; return(1); } $somevar = null; foo($somevar); Possible workarounds: allow_call_time_pass_reference can be set on per directory basis. @ can be added before function call (with side-effect of not displaying any errors of course) There's no other solution AFAIK.