Re: passing references multiple levels of function calls

From: Date: Tue, 22 May 2001 23:58:25 +0000
Subject: Re: passing references multiple levels of function calls
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-53956@lists.php.net to get a copy of this message
your close. <?php function f_of_A($var) { $var +=1; } function f_of_B($var) { $var %=3; } function do_both($vara, $varb) { f_of_A(&$vara); f_of_B(&$varb); } $gvara = 12; $gvarb = 13; do_both(&$gvara, &$gvarb); ?> the '&' goes in front of the variable being given, not in the function args. -- Chris Lee lee@mediawaveonline.com "Dennis Gearon" <gearond@oit.edu> wrote in message news:3B0AF273.7CF061B3@oit.edu... > I want to be able to do this: > > function f_of_A( &$vara ){ > $var +=1; > } > > function f_of_B( &$varb ){ > $var %=3; > } > > function do_both( &$vara, &$varb ){ > f_of_A( $vara ); > f_of_B( $varb ); > } > > $gvara=some_number; > $gvarb=some_other_number; > > do_both( $gvara, $gvarb ); > > and have the original, global variables altered by the 'f_of_X' > functions. > > The above structure and use of the '&' symbol DID NOT WORK, any ideas > why the > reference to the real contents did not get passed down? > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#53956) next »