how to print in console php code example
Example 1: php console log
<?php
function consoleLog($msg) {
echo '<script type="text/javascript">' .
'console.log(' . $msg . ');</script>';
}
consoleLog('Hello, console!');
?>
Example 2: console php
<?php
function console_log($msg) {
echo '<script>' .
'console.log("'.$msg .' ")</script>';
}
console_log("Hi there!");
?>
Example 3: php print to console
<script>
console.log(<?= json_encode($foo); ?>);
</script>
Example 4: php console print
$a = array(
null => 'a',
true => 'b',
false => 'c',
0 => 'd',
1 => 'e',
'' => 'f'
);
echo count($a), "\n";