How can I define a superglobal array in PHP?
I know that there is no way to do this. However I thought there might be some "brains" out there knowing about a workaround for it. Specifically I want to have an array on every .php file I have that has the same data. I also want to access it like this:
if( isset($_HANS["foo"]) && !empty( $_HANS["foo"] ) ) // DO
define( 'HANS', serialize( array( 'FooKey' => 'FooData' ) ));
$_HANS = array();
foreach(unserialize(HANS) as $Key => $Data)
$_HANS[$Key] = $Data;
$_DATA = array();
foreach( unserialize(HANS) as $Key => $Data )
$_DATA[$Key] = $Data;
$_HANS = getData();
You can declare
$myArray at the beginning of the script (you can use a prepend file), and then access it using
$GLOBALS['myArray'] from any point after that.