Jump to content

is there a way to echo out all the variables that are in use ?


jasonc

Recommended Posts

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.

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.