PHP 怎麼忽略某個函數拋出來的警告

來源:互聯網
上載者:User
PHP 如何忽略某個函數拋出來的警告
我在使用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);函數,但是又不想屏蔽掉其他警告。
有沒有辦法只屏蔽掉這個函數拋出來的警告?


或者有什麼方法提前做檢測繞過去也可以。

------解決方案--------------------
@socket_connect()
------解決方案--------------------
首先 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.
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.