I\'d like to debug some PHP code, but I guess printing a log to screen or file is fine for me.
How should I print a log in PHP code?
The u
Are you debugging on console? There are various options for debugging PHP. The most common function used for quick & dirty debugging is var_dump.
That being said and out of the way, although var_dump is awesome and a lot of people do everything with just that, there are other tools and techniques that can spice it up a bit.
Things to help out if debugging in a webpage, wrap
tags around your dump statement to give you proper formatting on arrays and objects.
Ie:
some html code ....
some link to test
dump $tpl like this:
And, last but not least make sure if debugging your error handling is set to display errors. Adding this at the top of your script may be needed if you cannot access server configuration to do so.
error_reporting(E_ALL);
ini_set('display_errors', '1');
Good luck!