The questions says everything. I am logging something on STDOUT.Should I use echo for displaying or Die()
.As far as I know If I use die() for normal printing like die('Entered in For loop')
, it exits the program. Also is it good to log to files or mysql?
For debugging I prefer var_dump()
. If you install Xdebug (http://xdebug.org/) in your development environment, you'll get a lot more out of var_dump.
When I want to kill a script I'm debugging, I wrap die around that, as in die(var_dump())
.
For logging, look into PHP's error_log()
(http://www.php.net/manual/en/function.error-log.php) function or a logging library such as monolog (https://github.com/Seldaek/monolog).
function dd($obj) {
$args = func_get_args();
$n = count($args);
for($i = 0; $i < $n; $i++) {
error_log(print_r($args[$i], true));
}
}