Skip to content

Instantly share code, notes, and snippets.

@vdite
Created July 7, 2013 11:43
Show Gist options
  • Save vdite/5943214 to your computer and use it in GitHub Desktop.
Save vdite/5943214 to your computer and use it in GitHub Desktop.
best way to debug php in the browser console
<?php
/**
* Send debug code to the Javascript console
*/
function debug_to_console($data) {
if(is_array($data) || is_object($data))
{
echo("<script>
if(console.debug!="undefined"){
console.log('PHP: ".json_encode($data)."');
}</script>");
} else {
echo("<script>
if(console.debug!="undefined"){
console.log('PHP: ".$data."');
}</script>");
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment