Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save k9t9/4e2e62dac52d53181e211b5278d0c77c to your computer and use it in GitHub Desktop.
Save k9t9/4e2e62dac52d53181e211b5278d0c77c 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