Last active
August 30, 2019 09:25
-
-
Save scsskid/6ca082f6d95379e8f9b8b1a4d3a2bb99 to your computer and use it in GitHub Desktop.
Debug PHP to Console JSON
This file contains hidden or 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_log($object = null, $label = null) | |
{ | |
$message = json_encode($object, JSON_PRETTY_PRINT); | |
$label = "Debug" . ($label ? " ($label): " : ': '); | |
echo "<script>console.log(\"$label\", $message);</script>"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
src: https://stackoverflow.com/a/21586930/2823589