View Single Post
Old 06-26-2009, 09:37 AM   #5 (permalink)
Costin Trifan
Meeow!
 
Costin Trifan's Avatar
 
Join Date: 04-13-07
Location: Romania
Posts: 3,235
iTrader: 0 / 0%
Latest Blog:
None

Costin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest order
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
Costin Trifan is offline   Reply With Quote