Re: references

From: Date: Tue, 22 Jul 2003 16:14:32 +0000
Subject: Re: references
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-156258@lists.php.net to get a copy of this message
It is perfectly legal to pass the variable by reference from one function to another. You'll see that $tmp is 2 at the end of this script. Ofcourse, if you leave off the reference operators you'll end up with 0. <?php function a(&$tmp){ $tmp++; b($tmp); } function b(&$tmp){ $tmp++; } $tmp = 0; a($tmp); ?> "Carl Furst" <carl@vote.com> wrote in message news:JDEJLFJKOCCJDAHBKCAEKEJGCGAA.carl@vote.com... > Ok lets see I have the following two functions one calls the other > > Function a (&$myref) { > > ..something... then calls function b > > b($myref); > > } > > function b (&$myref) { > > something > > } > > a($myref); > > is the reference by passing in function b legal??? > > > > Carl Furst > Chief Technical Officer > Vote.com > 50 Water St. > South Norwalk, CT. 06854 > 203-854-9912 x.231 > >

« previous php.general (#156258) next »