我在使用PHP 的socket_connect 函数时
如果SERVER不存在,那么这个函数会抛出一个
Warning: socket_connect() [function.socket-connect]: unable to connect [111]: Connection refused in /data/release/oc/trunk/system/class/Log.class.php on line 79
的警告我想屏蔽掉这个警告可以使用error_reporting(E_ALL ^ E_NOTICE);函数,但是又不想屏蔽掉其他警告。
有没有办法只屏蔽掉这个函数抛出来的警告?
或者有什么方法提前做检测绕过去也可以。

解决方案 »

  1.   

    @socket_connect()
      

  2.   

    首先 error_reporting(E_ALL ^ E_NOTICE); 不能屏蔽掉这个错误你可以用 @socket_connect() 来屏蔽错误的显示
    关于这个连接错误,手册中有
    如果成功则返回 TRUE,失败则返回 FALSE。 The error code can be retrieved with socket_last_error(). This code may be passed to socket_strerror() to get a textual explanation of the error.