문제

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));
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top