Debug code is be of several flavor :
var_dump
andprint_r
debug_print_backtrace
anddebug_backtrace
(the latter one has to be printed)$php_errormsg
variable (also when printed)ini_set
withdisplay_errors
andhtml_errors
directivesprint
orecho
with information (i.e.echo 'DEBUG';
. That includes HTML comments or$debug
messages.- Helper functions or classes, such as Kint, php-ref, dump_r, Krumo, dBug.
<?php
if (!is_object($dbconnexion)) {
debug($dbconnexion);
die();
}
?>
The most suited tool for debugging is a PHP debugger, that will run the code and give a full view of the situation, call stack and variable values. PHP debuggers also allow step by step execution. They are usually integrated with the IDE.
It is recommended to remove all mention to those tools in production code, so as to avoid situations where they are really used (and are in production).
The following patterns are considered warnings:
<?php
print 'debug';
require '/kint/Kint.class.php';
Kint::dump( $_SERVER );
?>