Debugging PHP can be a headache if you are not using any third party software/platform.
echo 'alert("Message to display!")';
Or if you want to display a variable, do the following:
For array, I would use this to view the array in the developer’s console:
var var_dump = <?php echo json_encode($var1); ?>;
If you know of any other way, let me know!
Edit: For those who use Firebug in Firefox browser, the answers in Stackoverflow here looks good: http://stackoverflow.com/questions/14995307/sending-var-dump-to-firebug-console