how to print to console php code example
Example 1: console.log in php
/*
console.log in php
*/
<?php
function consoleLog($message) {
echo '<script type="text/javascript">' .
'console.log(' . $message . ');</script>';
}
consoleLog('Hello, greppers!');
?>
Example 2: php print to console
<script>
console.log(<?= json_encode($foo); ?>);
</script>