return local variable as reference -- ok?

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(&...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-13-2003
Lim Kean Heng
 
Posts: n/a
Default return local variable as reference -- ok?

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
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:42 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0