Last active
October 4, 2021 11:04
-
-
Save sdrwtf/ba7bbfc9b5e93a34d82c6c096e123f92 to your computer and use it in GitHub Desktop.
Simple function to write to dev-tools console log
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 | |
// Ment to be used within an existing class | |
$this->console_log('log me'); | |
/** | |
* Simple function to write to dev-tools console log | |
* @param $output Whatever shall be pushed to the log | |
* @param boolean $with_script_tags Flag to enable <script> tags | |
*/ | |
private function console_log($output, $with_script_tags = true) { | |
$js_code = 'console.log(' . json_encode($output, JSON_HEX_TAG) . ');'; | |
if ($with_script_tags) { | |
$js_code = '<script>' . $js_code . '</script>'; | |
} | |
echo $js_code; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment