06-26-2009, 09:37 AM
|
#5 (permalink)
|
|
Meeow!
Join Date: 04-13-07
Location: Romania
Posts: 3,235
Latest Blog: None
|
np.
just imagine you have a file where you declare many variables. They will all be defined in the global scope, now you want to access those variables in other inner pages so you would normally use extract($GLOBALS); which will give you full access to those vars.
But my problem with that is that I don't want all those variables, only some of them, so I need a function that will filter the $GLOBALS variable and return a new filtered array:
PHP Code:
$globals = $GLOBALS;
// to do: filter globals
$filtered_globals = exclude_globals( array('_POST', '_GET', '_SESSION', 'cs', 'other_object') );
extract($filtered_globals);
and now I'll have access to al global variables except the ones I excluded using the function.
Ex: if I'd print this out now:
PHP Code:
var_dump($cs); // the connection string array
it should throw an error, because the $cs array was excluded.
see what I mean now?
__________________
...to be continued
|
|
|