Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Debug Echo's

Tags:

php

debugging

Just wondering -

When debuging PHP - how do you like to output the test data to see whats going on? I've been noticing that alot of my PHP echo testing is screwing with my CSS. Does anyone have a good clean method of seeing the results without screwing with the site itself?

like image 830
Chud37 Avatar asked Jul 02 '12 13:07

Chud37


3 Answers

You should try error_log function. It will log your debug output directly into the web server logs, and not in your page.

Another way is to echo between comments markups:

echo '<!-- This is a debug message! -->';
like image 143
Jonathan Petitcolas Avatar answered Oct 20 '22 19:10

Jonathan Petitcolas


I like to use:

error_log("message and vars here");

It depends on the server configuration, but if you can use it, you get a nice log-file. Very useful.

like image 35
ZeeCoder Avatar answered Oct 20 '22 17:10

ZeeCoder


Yes, use the Apache error log, if you have that kind of setup, with tail -f. Use the error_log function found here.

like image 21
Travis Pessetto Avatar answered Oct 20 '22 17:10

Travis Pessetto