Skip to content

Instantly share code, notes, and snippets.

@technoknol
Last active August 5, 2017 04:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save technoknol/78a3f85835888e464f57 to your computer and use it in GitHub Desktop.
Save technoknol/78a3f85835888e464f57 to your computer and use it in GitHub Desktop.
Send print_r to Firebug Console.log
<?php
function debug ($data) {
echo "<script>\r\n//<![CDATA[\r\nif(!console){var console={log:function(){}}}";
$output = explode("\n", print_r($data, true));
foreach ($output as $line) {
if (trim($line)) {
$line = addslashes($line);
echo "console.log(\"{$line}\");";
}
}
echo "\r\n//]]>\r\n</script>";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment