If you will write inside the console of your browser, then use one of a lot of helpers or use a small custom function in php. The follow function is easy to use and log inside the console of the browser.
if ( ! function_exists( 'debug_to_console' ) ) {
/**
* Simple helper to debug to the console
*
* @param object, array, string $data
* @return string
*/
function debug_to_console( $data ) {
$output="";
$output .= 'console.info( \'Debug in Console:\' );';
$output .= 'console.log(' . json_encode( $data ) . ');';
echo '<script>' . $output . '</script>';
}
}
A image say more:
Alternative use a library, like ChromePHP for Chromium Project, Webug for many different browsers or FirePHP as example. Is give a lot more helpers in this topic.
If you will work this inside WordPress, then is a fast a easy to use helper the plugin Debug Objects, this plugin have the source from the easy to use funtione above inside the plugin and also the CromePHP library.