php output stuff in console code example
Example 1: console php
//display message in console
<?php
function console_log($msg) {
echo '<script>' .
'console.log("'.$msg .' ")</script>';
}
console_log("Hi there!");
?>
Example 2: php print to console
<script>
console.log(<?= json_encode($foo); ?>);
</script>