write to console from php code code example Example: php print to console <script> console.log(<?= json_encode($foo); ?>); </script>