Skip to content

Instantly share code, notes, and snippets.

@developius
Last active October 22, 2015 11:49
Show Gist options
  • Save developius/0b400fdb56efb5e683f7 to your computer and use it in GitHub Desktop.
Save developius/0b400fdb56efb5e683f7 to your computer and use it in GitHub Desktop.
Useful PHP debugging functions
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