Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

debugging PHP

Status
Not open for further replies.

DaveC426913

Programmer
Jul 28, 2003
274
CA
How can I reliably debug PHP by displaying the contents of variables?

The pages I'm debugging are doing various things that might or might not generate an HTML page, redirect to another page or run a shell script. The very act of echo'ing a variable may mess with the operation of the script (especially if it hasn't printed the header yet).

While I'm at it, same question about shell scripting.
 
couple of ideas:

add
Code:
ob_start();
to the start of each page.

and then plug a footer or something with your variables output eg
Code:
function footer() {
  echo "<pre>";
  get_defined_variables();
  echo "</pre>";
}
 
sorry - didn't read your post properly. the above only works with outputted web pages.

to cater to every solution you might want to push the output to a text file.

or as sleipnir214 says, use error_log (perhaps with a custom error handling function)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top