Consolelog In Php Code Example


Example 1: php console log


// Assuming you are wishing to log to the JS Console...

<?php
function consoleLog($msg) {
echo '<script type="text/javascript">' .
'console.log(' . $msg . ');</script>';
}

consoleLog('Hello, console!');
?>

Example 2: 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 3: php print to console


<script>
console.log(<?= json_encode($foo); ?>);
</script>

Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable