Although Paul describes what is happening, I will try to explain again.
When you create a variable, it belongs to a specific area. A region is a region in which a variable can be used.
For example, if I did this
$some_var = 1; function some_fun() { echo $some_var; }
a variable is not allowed inside a function because it was not created inside a function. For it to work inside the function, you must use the global keyword, so the example below will work
$some_var = 1; function some_fun() { global $some_var;
It is the other way around, so you cannot do the following
function init() { $some_var = true; } init(); if($some_var)
There are several ways to do this, but the simplest of them is to use the $GLOBALS array, which is allowed anywhere in the script, as it is special variables.
So,
$GLOBALS['config'] = array( 'Some Car' => 22 ); function do_something() { echo $GLOBALS['config']['some Car']; //works }
Also, make sure your server has global registration registers disabled in your INI for security. http://www.php.net/manual/en/security.globals.php
RobertPitt
source share