jasonc Posted December 14, 2011 Share Posted December 14, 2011 What I would like to find out is how I can echo out all the variables that are in use in the visitors visit. And have these echoed on the page. (for error checking purposes) some of my variables i.e. $username or $email and a few others are being cleared of its content and I can not find any problems searching all the files for the variable name and checking the lines but think that some other variable is in turn causing theproblems. so wanting to find a way to place an echo line that shows all the variables and then have the next line exit; and just move these two new lines around my scripts to find out where the problems might be. Quote Link to comment https://forums.phpfreaks.com/topic/253171-is-there-a-way-to-echo-out-all-the-variables-that-are-in-use/ Share on other sites More sharing options...
xyph Posted December 14, 2011 Share Posted December 14, 2011 the $GLOBALS 'superglobal' array is one big reference to variables in the global scope. http://php.net/manual/en/reserved.variables.globals.php print_r( $GLOBALS ); You should only use $GLOBALS for debugging. Quote Link to comment https://forums.phpfreaks.com/topic/253171-is-there-a-way-to-echo-out-all-the-variables-that-are-in-use/#findComment-1297907 Share on other sites More sharing options...
Psycho Posted December 14, 2011 Share Posted December 14, 2011 Also, instead of moving the debugging code around, I would suggest creating a debugging function that you can reference many places in your script. Make the function so that you can set a value to determine whether debugging is on or off. If off,t he function does nothing. You could also have the function compare the GLOBAL values between calls so you can see where the value is getting set or changes. Quote Link to comment https://forums.phpfreaks.com/topic/253171-is-there-a-way-to-echo-out-all-the-variables-that-are-in-use/#findComment-1297931 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.