Re: [PHP] Making varibles (more than one) with a function.
David: makevars() { list($md5,$pusername,$pproject,$pfile) = explode(:,$authok); $user = $pusername; $project = $pproject; $file = $pfile; } Uh, why are you wasting memory and time by reassigning the variables? Why not call the variables what you want them to be in the first place? makevars() { list($md5, $user, $project, $file) = explode(':', $authok); } How could I have a function create variables that can be used in other functions? A few options. 1) Assign them to some other array and then declare that array global in the creatingn and receiving functions. makevars() { global $Vars; list($Vars['md5'], $Vars['user'], $Vars['project'], $Vars['file']) = explode(':', $authok); } function other() { global $Vars; echo $Vars['md5']; } 2) Assign the stuff to the $GLOBALS[] array. function makevars() { list($GLOBALS['md5'], $GLOBALS['user'], $GLOBALS['project'], $GLOBALS['file']) = explode(:,$authok); } function other() { echo $GLOBALS['md5']; } 3) Declare each variable global in the creatingn and receiving functions. makevars() { global $md5, $user, $project, $file; list($md5, $user, $project, $file) = explode(':', $authok); } makevars() { global $md5, $user, $project, $file; echo $md5; } Enjoy, --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Making varibles (more than one) with a function.
If that works than the why does test file I tried previously to making the post return a $text does not exist error? ? echoo(); function test() { $text = Testing; global $text; } function echoo() { test(); echo $text; } ? Sqlcoders.Com Programming Dept [EMAIL PROTECTED] wrote in message 009f01c20241$f05aaf80$6520fea9@dw">news:009f01c20241$f05aaf80$6520fea9@dw... Sqlcoders.com Dynamic data driven web solutions - Original Message - From: David Duong [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: May 22 2002 04:21 PM Subject: [PHP] Making varibles (more than one) with a function. I am aware that return can return strings but is their a set global or a function similar to return? hi there!, There sure is, it's called global. Usage: global $variable_a; global $variable_b; global $variable_c; ... HTH, Dw. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Making varibles (more than one) with a function.
Because global is specific to the SCOPE not to the variable - variables themselves aren't tagged as global. If you add global $text; in your echoo() function it will work. Alternatively, you could replace echo $text; with echo $GLOBALS['text']; in your echoo() function. See http://www.php.net/manual/en/language.variables.php for more info. -steve At 3:17 PM -0600 5/23/02, David Duong wrote: If that works than the why does test file I tried previously to making the post return a $text does not exist error? ? echoo(); function test() { $text = Testing; global $text; } function echoo() { test(); echo $text; } ? Sqlcoders.Com Programming Dept [EMAIL PROTECTED] wrote in message 009f01c20241$f05aaf80$6520fea9@dw">news:009f01c20241$f05aaf80$6520fea9@dw... Sqlcoders.com Dynamic data driven web solutions - Original Message - From: David Duong [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: May 22 2002 04:21 PM Subject: [PHP] Making varibles (more than one) with a function. I am aware that return can return strings but is their a set global or a function similar to return? hi there!, There sure is, it's called global. Usage: global $variable_a; global $variable_b; global $variable_c; ... HTH, Dw. -- ++ | Steve Edberg [EMAIL PROTECTED] | | University of California, Davis (530)754-9127 | | Programming/Database/SysAdmin http://pgfsun.ucdavis.edu/ | ++ | If only life would imitate toys. | | - Ted Raimi, March 2002 | | - http://www.whoosh.org/issue67/friends67a.html#raimi | ++ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Making varibles (more than one) with a function.
Sqlcoders.com Dynamic data driven web solutions - Original Message - From: David Duong [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: May 22 2002 04:21 PM Subject: [PHP] Making varibles (more than one) with a function. I am aware that return can return strings but is their a set global or a function similar to return? hi there!, There sure is, it's called global. Usage: global $variable_a; global $variable_b; global $variable_c; ... HTH, Dw. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php