0

我有删除文件的功能。这是我的代码:

echo error_reporting();     // got 32767 = E_ALL, yes?
ini_set('display_errors',0);
if(unlink($file) == false){
    echo "Error";
}

我收到以下错误:

字符串(274)“问题取消链接(/path/to/file.mp4):第 1226 行 /path/to/script.php 中的权限被拒绝

如何在日志文件上记录我的错误,而不是在屏幕上?

4

5 回答 5

1

您可以将自己的错误处理程序与函数 set_error_handler()一起使用

您可以在传递给 set_error_handler() 的函数中编写日志记录

该函数还有一个名为error_types的参数,您可以在其中提供要处理的错误类型。是否显示它们取决于您。

我不会写其他选项,因为其他人已经提到过它们。

于 2013-07-08T10:07:20.967 回答
0

you can use error_log() and for suppress the error in frontend you can use error_reporting(0)

于 2013-07-08T10:00:57.277 回答
0

The reason why it doesn't work is because in PHP 5.2.4 and up the variable has changed from boolean to string. Set display_errors to 'stderr' instead.

于 2013-07-08T10:01:03.017 回答
0

→ Try this:

This will work at runtime:

     ini_set( 'display_errors', '0' );

This will stop errors from being displayed but they will still be logged. This will stop both:

     error_reporting(0); // Will stop both error displaying and reporting to screen
于 2013-07-08T10:01:08.147 回答
0

它是其他脚本上的 var_dump() 捕获错误并将其显示在屏幕上。

于 2013-07-08T10:12:49.513 回答