Created
January 18, 2020 07:19
-
-
Save nyancodeid/ef044ab7a22e999da7e6aa721b87642a to your computer and use it in GitHub Desktop.
Logging PHP Variable into console.log javascript
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 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; | |
| } | |
| console_log($getIncrement); | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment