global variables headache
| From: | Jon Lauridsen | Date: | Tue, 02 Apr 2002 02:20:51 +0000 |
| Subject: | global variables headache | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-12882@lists.php.net to get a copy of this message | ||
Hey all,
I'm fairly new to PHP (heck, to programming heh), so my hopes is that this problem of mine is
an easy one to solve.
I also don't know how classic this question is, but I think it must be something that most come
across at some point. I'm caught in the trap that is PHPs local variables. I have failed to
globalize anything thus far, despite looking in the manual, google, and talking to a
codemonkey-friend. I think an example will show what wall I'm hitting:
<?
require( "include.inc" );
echo( $var );
?>
and the include.inc file has:
<?
$var = "whatever";
?>
So I'm not defining the variable within a function, in which the scope apparently keeps
everything localized (a good thing as far as I can tell). I just thought variables defined outside a
function were in the safe, but I guess not..
Kinda obviously this is not a copy-paste of my actual project :), but if I can just get that to work
I'll be able to move all of my color-definitions to a seperate file and control things from
there. I do, though, have a history full of odd routes I've taken to get things working,
forgetting the valuable KISS rule in the process heh.
If this is the case here I welcome advise on how else to deal with defining colors from a central
page.
With regards
Jon Lauridsen
mail@jonlauridsen.com