Forum Moderators: coopster

Message Too Old, No Replies

arrays and functions

         

Code Sentinel

4:48 am on Jul 20, 2005 (gmt 0)

10+ Year Member



if you pass an array to a function by reference do you need to return at the end still?

and to clarify a few more things...

when creating the function does it need to be:

function processit($a) {
}

or

function &processit($a) {
}

if I want to work with arrays by reference, or would just passing the array by reference:

processit(&$a)

be enough? and again back to first question.. if it's passed by reference do I need to return the array or just a blank return? ex return;

Code Sentinel

6:05 am on Jul 20, 2005 (gmt 0)

10+ Year Member



upon further testing I find that passing by reference like:

funcname(&$a);

is deprecated (my allow_call_time_pass_reference was off). The exact warning is:

Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of [runtime function name]().

does this mean I need to declare functions as such:

function &funcname($a) {}

if I want it to pass everything to it by reference by default? Or would it just be better to turn on allow_call_time_pass_reference in the php.ini file?

dcrombie

10:17 am on Jul 20, 2005 (gmt 0)



does this mean I need to declare functions as such:

function &funcname($a) {}

No, what you want is:

function funcname(&$a) {}

;)