It's been extremely handy to use CLI with testing the examples.
I am here proposing a univeral way for both browser and CLI output:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 'On');
// Output handler
ob_start(function($buffer){
return (php_sapi_name() != 'cli') ? '<pre>'.htmlspecialchars($buffer).'</pre>' : $buffer;
});
// Do your stuff
// ...
var_dump('some output');