How do I log speed benchmarks to a console in php? I don’t want to echo
the results for the user to see, but just in some kind of log.
I know that I can get the time elapsed with this:
$first = new DateTime( '11:35:20' );
$second = new DateTime( '12:00:45' );
$diff = $first->diff( $second );
echo $diff->format( '%H:%I:%S' ); // -> 00:25:25
but I want to log the time, and not echo
it. Do I use the error_log?
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.
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.