Want to console.log() your php?

Here is a simple way:


function console_log( $data ){
echo '<script>';
echo 'console.log('. json_encode( $data ) .')';
echo '</script>';
}


Usage:
$myvar = array(1,2,3);
console_log( $myvar ); // [1,2,3]

2 thoughts on “Want to console.log() your php?

Comments are closed.