Last active
January 9, 2017 09:14
-
-
Save Chukatuk/64ab7048f842de94a0008119f511c4de to your computer and use it in GitHub Desktop.
php debug to 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
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