This is a discussion on return local variable as reference -- ok? within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi all, I have some questions about the return array & reference... function &node_factory() { // local varible $newnode $newnode=array(&...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi all,
I have some questions about the return array & reference... function &node_factory() { // local varible $newnode $newnode=array("No", "OO"); return $newnode; } $mynode0=node_factory(); $mynode1=node_factory(); $mynode2=&node_factory(); $mynode3=&node_factory(); Is that correct that 1. $mynode0 and $mynode1 are two new arrays, because the array are return (copy) using pass-by-value methods. 2. $mynode2 and $mynode3 are the same array because they are refer to $newnode in function node_factory. However, since the $newnode is local variable of a function. Are the references valid? Thanks in advanced. Regards, KeanHeng |