Last active
September 1, 2016 22:05
-
-
Save flydev-fr/cc4589be264889cfac6bd2b928b046d7 to your computer and use it in GitHub Desktop.
debug function, outptut in console dev. browser
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 | |
// debug function | |
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