如何打开所有错误和警告并将它们记录到文件中,但要在脚本中设置所有这些(不更改 php.ini 中的任何内容)?
我想定义一个文件名,以便将所有错误和警告都记录到其中。
最佳答案
使用以下代码:
ini_set("log_errors", 1);
ini_set("error_log", "/tmp/php-error.log");
error_log( "Hello, errors!" );
然后看文件:
tail -f /tmp/php-error.log
或更新 php.ini
,如 this blog entry 中所述从 2008 年开始。
关于php - 如何将错误和警告记录到文件中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3531703/