sorry, my test case isn't exactly indicative of my needs. I was just trying to illustrate the failure of assigning a global pointer within a function.
The availability (or lack thereof) of $b in the global namespace is not the issue.
I will tell you about my real-world needs.
I have several global arrays used by my application, such as $CONFIG, $CACHE, $_THEME, etc.
within each file and/or function I go a "global $_CONFIG" (or what-have-you) to ensure they are available.
My newer, more elegant code uses an object to store all the variables to prevent pollution of the global namespace. Granted, I still have to keep track of one global variable (the object), but it's at least somewhat cleaner.
For example:
$_VARS = new VarStore;
$_VARS->addVar('_CONFIG', array());
these variables are public, and do not require using a class method to retreive their values, but one can be used if wanting to perform certain checks (existence, type, etc.)
But usually they are manipulated via:
$VARS->variables['CONFIG']['db_name'] = 'mydatabase';
$VARS->variables['THEME']['site_col_bg'] = '#ffffff';
and so forth..
but so that existing third-party code is not broken, I am trying to reference the new Variable Store arrays with the old global arrays
for example, in the top of my config.php file I may have:
global $_VARS;
$_VARS->addVar('_CONFIG', array());
global $_CONFIG;
$_CONFIG =& $_VARS->variables['_CONFIG'];
the problem is that if I try to read $_CONFIG in any other scope it is empty, and if I were to do something like:
global $_VARS;
$_VARS->addVar('_CONFIG', array());
global $_CONFIG;
$_CONFIG = 'dummy value';
$_CONFIG =& $_VARS->variables['_CONFIG'];
and elsewhere do:
global $_CONFIG;
echo $_CONFIG;
it would be 'dummy_value' instead of 'Array'
does this make any sense? I'm not the best at trying to explain things. Apologies.