Last active
August 29, 2015 14:16
-
-
Save ChriRas/a40d6df366ec968b380e to your computer and use it in GitHub Desktop.
Simple PHP Debug with var_dumb, print_r and print_r to js-Console
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 | |
print __FILE__ . " " . __LINE__." "; | |
var_dump($variable); | |
die; | |
?> |
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
print "<pre>" . '<b>File:</b>' . __FILE__ . '<br><b>Line:</b>' . __LINE__ . '<br>' . print_r($variable, 1) . "</pre>"; |
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
//DEBUG to JS-Console | |
$tmpDebug =$variable; | |
echo "<script>\r\n//<![CDATA[\r\nif(!console){var console={log:function(){}}}"; | |
echo "console.log(\" File: " . __FILE__ . " \");"; | |
echo "console.log(\" Line: " . __LINE__ . " \");"; | |
foreach (explode("\n", print_r($tmpDebug, true)) as $line) { | |
if (trim($line)) { | |
$line = addslashes($line); | |
echo "console.log(\"{$line}\");"; | |
} | |
} | |
echo "\r\n//]]>\r\n</script>"; | |
//END DEBUG |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment