I have a reason why I need to do this.... It's a code related... what I want to know if possible is how I can display or list all available variables in the php file I am opening.. For example this is the content of the a.php file <?php $a = "wala"; $my="name."; echo "this is something"; $another = ""; ?> Now I want to list all available variable names at a.php, is there a way to do that... display the $a , $my, $another with out hard coding it.
Try this: <?php $a = 'wala'; $my = 'name'; $another = ''; $defined = get_defined_vars(); $exclude_list = 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'); foreach ($exclude_list as $exclude) { unset($defined[$exclude]); } echo "<pre>"; print_r($defined); echo "</pre>"; ?> PHP: