note 100302 modified in function.var-export by danbrown

From: Date: Wed, 06 Oct 2010 20:59:00 +0000
Subject: note 100302 modified in function.var-export by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-173040@lists.php.net to get a copy of this message
Try this function instead of var_export($GLOBALS) or var_dump($GLOBALS) when all you want to know is the values of the variables you set on the current page. <?php function globalvars(){ $result=array(); $skip=array('GLOBALS','_ENV','HTTP_ENV_VARS', '_POST','HTTP_POST_VARS','_GET', 'HTTP_GET_VARS', '_COOKIE', 'HTTP_COOKIE_VARS','_SERVER', 'HTTP_SERVER_VARS', '_FILES','HTTP_POST_FILES', '_REQUEST','HTTP_SESSION_VARS', '_SESSION'); foreach($GLOBALS as $k=>$v) if(!in_array($k,$skip)) $result[$k]=$v; return $result; }//functionglobalvars var_export(globalvars()); ?> --was-- Try this function instead of var_export($GLOBALS) or var_dump($GLOBALS) when all you want to know is the values of the variables you set on the current page. function globalvars(){ $result=array(); $skip=array('GLOBALS','_ENV','HTTP_ENV_VARS', '_POST','HTTP_POST_VARS','_GET', 'HTTP_GET_VARS', '_COOKIE', 'HTTP_COOKIE_VARS','_SERVER', 'HTTP_SERVER_VARS', '_FILES','HTTP_POST_FILES', '_REQUEST','HTTP_SESSION_VARS', '_SESSION'); foreach($GLOBALS as $k=>$v) if(!in_array($k,$skip)) $result[$k]=$v; return $result; }//functionglobalvars var_export(globalvars()); http://php.net/manual/en/function.var-export.php

« previous php.notes (#173040) next »