The standard output will look like this:
<full file path> <Line>::<Class>::<Method> <Time> || <Elapsed Time> <Label>: <Value>
Example:
C:\xampp\htdocs\debug\examples.php 65::testClass::testMethod 01:09:45:673 || 00:00:00:001 $test: My Test Stringincluding both the files because they are used in the examples
require_once 'print_d.php'; require_once 'debug.php'; $test = 'example'; $array = array('foo' => 'value', 'bar' => 'value');basic usage - no parameters
print_d();
C:\xampp\htdocs\debug\examples.php 22::none::none 16:20:35:109 || 00:00:00:000basic usage - variable
print_d($test);
28::none::none 16:20:35:109 || 00:00:00:000 $test: examplebasic usage, defined constant
print_d(__LINE__);
33::none::none 16:29:01:228 || 00:00:00:000 __LINE__: 29basic usage, string
print_d('hello world');
38::none::none 16:33:36:943 || 00:00:00:001 hello worldbasic usage, array in variable
print_d($array);
44::none::none 16:44:30:386 || 00:00:00:001 $array: Array ( [foo] => value [bar] => value )basic usage, variable, backtrace level == 0
print_d($test, 0);
$test: examplebasic usage, variable, backtrace level 3
print_d($test, 3);
63::none::none 16:41:45:527 || 00:00:00:001 none::none::none none::none::none $test: exampleusing the debug class works exactly the same way
$bug = new debug(); $bug->out($test); $bug->out(__LINE__, 0); $bug->out($array, 0);
73::none::none 16:54:52:084 || 00:00:00:001 $test: example __LINE__: 75 $array: Array ( [foo] => value [bar] => value )using the multi parameter call
multi_d($test, __LINE__, $array);OR
$bug->multi($test, __LINE__, $array);
89::none::none 17:47:17:478 || 00:00:00:001 $test: example __LINE__: 90 $array: Array ( [foo] => value [bar] => value )there are configuration values which can be changed.
$config['addTime'] = false; $config['traceLevel'] = 2; $config['useLabels'] = false; setup_d($config); print_d($test);
115::none::none none::none::none examplethis setup will effect the default instance - used by both print_d and by the class unless it's instantiated otherwise
$bug->out($test);
122::none::none none::none::none exampleone of the things which makes the class more versatile, is the ability to set up more than one instance by passing in an identifier upon instantiation note that the output from this class will be the default output and will include the file path, because the it's a new instance
$new = new debug('new'); $new->out($test);
C:\xampp\htdocs\debug\examples.php 131::none::none 18:23:04:653 || 00:00:00:001 $test: examplethe default instance is still set up the way it was
print_d($test);
138::none::none none::none::none exampleif we change the configuration on the new instance, it effects only that instance. this feature is especially useful for printing different kinds of output to multiple output files
$new->setup(array('useWebTags' => false)); $new->out($array);
149::none::none 18:37:13:294 || 00:00:00:001 $array: Array ( [foo] => value [bar] => value )this instance will be set up to do pretty timer output. There will be a space in the output only before a file name is printed. Timer output is best done to a file, where it's easy to read.
$timer = new debug('timer'); $timer->setup(array('timerSpacing' => true)); $timer->out(); (do something for six microseconds) $timer->out(); $timer->out(); $timer->out();
C:\xampp\htdocs\debug\examples.php 158::none::none 20:33:47:048 || 00:00:00:000 162::none::none 20:33:47:054 || 00:00:00:006 163::none::none 20:33:47:054 || 00:00:00:000 164::none::none 20:33:47:054 || 00:00:00:000