Skip to content

Instantly share code, notes, and snippets.

@millsoft
Created August 16, 2019 12:27
Show Gist options
  • Save millsoft/7a379d3a25db908a6336695d28af9a80 to your computer and use it in GitHub Desktop.
Save millsoft/7a379d3a25db908a6336695d28af9a80 to your computer and use it in GitHub Desktop.
console.log for php print php Variables in Browser console
<?php
function console_log ($data)
{
$bt = debug_backtrace();
$caller = array_shift($bt);
$caller_string = "{$caller['file']}:{$caller['line']}";
$d = json_encode($data);
$html = <<<html
<script>
/* {$caller_string} */
console.log({$d});
</script>
html;
echo $html;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment