Forked from technoknol/send-print_r-to-firebug-console.php
Created
August 5, 2017 04:23
-
-
Save k9t9/4e2e62dac52d53181e211b5278d0c77c to your computer and use it in GitHub Desktop.
Send print_r to Firebug Console.log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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