Last active
October 22, 2015 11:49
-
-
Save developius/0b400fdb56efb5e683f7 to your computer and use it in GitHub Desktop.
Useful PHP debugging functions
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
This code is licensed under the Apache 2.0 license available here: http://www.apache.org/licenses/LICENSE-2.0.html | |
function debug($a) { | |
if (is_string($a) || is_int($a)) { | |
echo $a."<br>"; | |
} | |
else { | |
echo "<pre>"; | |
print_r($a); | |
echo "</pre>"; | |
} | |
} | |
function jslog($text) { | |
echo "<script type='text/javascript'>"; | |
if (is_string($text) || is_int($text)) { | |
echo "console.log('".$text."');"; | |
} | |
else { | |
echo "console.log(JSON.stringify(".json_encode($text)."));"; | |
} | |
echo "</script>"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment