Wierd Variable Initialization
| From: | VamVan | Date: | Thu, 25 Sep 2008 02:44:39 +0000 |
| Subject: | Wierd Variable Initialization | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-280898@lists.php.net to get a copy of this message | ||
So guys,
I found some thing strange that happened to me yesterday. Its small but
kinda freaked me out.
So I have a tokenmap.php that I include include in different configuration
files. Some are classes and some are simple php files.
So in my tokenmap.php I have declared an array as global.
SO $GLOBAL['tokenmap'] = array()
As a good programming practice what I did was:
require_once('tokenmap.php');
$tokenmap = array();
$tokenmap = $GLOBAL['tokenmap'];
print_r($tokenmap);
The above displays empty array
But when I do this , it works
require_once('tokenmap.php');
$tokenmap = $GLOBAL['tokenmap'];
print_r($tokenmap);
Its kind of wierd for me. I am trying to understand. Can some one shed some
light on it for me.
Thanks