Re: Using a string from another function
| From: | Joe Stump | Date: | Mon, 06 Nov 2000 05:16:05 +0000 |
| Subject: | Re: Using a string from another function | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-23843@lists.php.net to get a copy of this message | ||
Are you putting $colorX in as globals in the second function?
--Joe
On Mon, Nov 06, 2000 at 02:52:49PM +1100, Chris Aitken wrote:
> 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
================================================================================
= Joe Stump joestump98@yahoo.com http://www.miester.org =
================================================================================
"Real programmers don't comment their code.
It was hard to write, it should be hard to understand."