RE: [PHP] Using a string from another function

From: Date: Mon, 06 Nov 2000 03:57:41 +0000
Subject: RE: [PHP] Using a string from another function
Groups: php.general 
Request: Send a blank email to php-general+get-23834@lists.php.net to get a copy of this message
try setting them to something before the first function is called. -- Jason Murray jasonm@melbourneit.com.au Web Design Team, Melbourne IT Give me ambiguity or give me something else. > -----Original Message----- > From: Chris Aitken [mailto:chris@ideal.net.au] > Sent: Monday, November 06, 2000 1:53 PM > To: Joe Stump > Cc: php-general@lists.php.net > Subject: Re: [PHP] Using a string from another function > > > At 06:57 PM 5/11/2000, Joe Stump wrote: > >You need to declare them global before you assign something to them. > > > >so do this: > > > >function color_scheme($scheme){ > > global $color1, $color2; > > if($scheme ==1){ > > $color1 = '#FFFFFF'; > > $color2 = '#000000'; > > } > >} > > > I had tried this first actually, and still no go. > > Whenever I call another function further in the php script, > it doesnt know > the value of $color1 or $color2 > > For example, here is the basic rundown of how I do it............... > > -------------------------------------------------------------- > ---------- > > functions.inc > > function color_scheme { > assigns the $color1 and $color2 and sets globally; > based on the assigned value from the main php file > } > > function table_stuff { > called by the main php file, with an array of data; > also uses both $color1 and $color2 in its function; > } > > > -------------------------------------------------------------- > ----------- > > > main.php > > <? > include("functions.inc") > > //sets the color scheme to 1's values > color_scheme(1); > > //lays out the table data as per the function. This > function is supposed > //to call on the previously set global values of $color1 and $color2 > table_stuff(array("blah blah","more blah")); > > > ?> > > -------------------------------------------------------------- > ------------ > > > In a nutshell, thats the desired effect. From the main file, > firstly set > the color scheme and make the values global, then run any > other functions > and make the color scheme values available to all other > functions if needed. > > > > Chris > > > -- > 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 (#23834) next »