php print post in console 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: console_log in php
<?php
function console_log($output, $with_script_tags = true) {
$js_code = 'console.log(' . json_encode($output, JSON_HEX_TAG) .
');';
if ($with_script_tags) {
$js_code = '<script>' . $js_code . '</script>';
}
echo $js_code;
}