如何将 PHP error_log() 语句回显到输出缓冲区

Zug*_*alt 5 php phpunit error-log echo phpstorm

我使用PHPStorm开发 PHP Web 应用程序并使用其内置的 PHPUnit 测试运行器。在 IDE 的输出窗口中,它显示输出缓冲区(例如,已回显的任何内容)。

ini_set('display_errors', 'On')我可以看到使用和出现的错误error_reporting(E_ALL)。但是,使用的任何输出都error_log()不会显示(但会在错误日志中显示)。

有没有办法让写入错误日志的任何内容也显示在输出缓冲区中?

Nie*_*sol 0

很简单:包装函数。

function error_log_out($message, $message_type=0, $destination=0, $extra_headers="") {
    error_log($message,$message_type,$destination,$extra_headers);
    echo $message; // optionally add some formatting
}
Run Code Online (Sandbox Code Playgroud)