asmith Posted July 26, 2009 Share Posted July 26, 2009 Hi, <?php $a = 3; $b = 'string'; $c = array('4' => 'text'); ?> Where the list of the variables are stored? I need to check some script to see what variables are in the memory. I used to get that list, Something to do with globals? I've completely forgotten. Thanks Link to comment https://forums.phpfreaks.com/topic/167471-solved-getting-the-list-of-variables-that-have-been-defined/ Share on other sites More sharing options...
Zyx Posted July 26, 2009 Share Posted July 26, 2009 Check out the following script: <?php function xyz() { $a = 5; $b = 45; $c = 38; var_dump(get_defined_vars()); var_dump($GLOBALS); } // end xyz(); $d = 65; xyz(); The array $GLOBALS contains the list of current global variables, so it shows only the variable $d, even if we access it from the function. On the other hand, we have get_defined_vars() which returns the list of the variables in the current scope. Link to comment https://forums.phpfreaks.com/topic/167471-solved-getting-the-list-of-variables-that-have-been-defined/#findComment-883073 Share on other sites More sharing options...
asmith Posted July 26, 2009 Author Share Posted July 26, 2009 Thanks mate, It was $GLOBALS which I was looking for. don't know why I tried $globals. didn't notice the capitals lol Thanks again Link to comment https://forums.phpfreaks.com/topic/167471-solved-getting-the-list-of-variables-that-have-been-defined/#findComment-883081 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.