错误控制操作员不工作

时间:2011-07-07 12:17:28

标签: php

我的问题类似于one。但是,error control operator对我不起作用。

使用以下代码:

$this->fp = @fsockopen($this->ip, $this->port, $errno, $errstr, $this->timeout);

我仍然收到错误消息:

fsockopen(): unable to connect to xxx.xxx.xxx.xx:xxxxx (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. )

我是否可以禁用错误控制操作符?

1 个答案:

答案 0 :(得分:2)

我发现了问题!我一直在使用自己的错误处理程序

set_error_handler('my_error_handler');

如果@有前缀,它会打印出错误。

FYI - 来自php manual的代码演示了如何在用户定义的错误处理程序中抑制错误:

// if error has been supressed with an @
if (error_reporting() == 0) {
    return;
}