php報錯提示 PHP Notice: curl_setopt(): CURLOPT_SSL_VERIFYHOST with value 1 is deprecated and will be removed as of libcurl 7.28.1. It is recommended to use value 2 instead in

字號+ 編輯: 国内TP粉 修訂: 听风就是我 來源: 2023-09-09 我要說兩句(0)

7.2之後的php比較調皮地廢除了之前的一些寫法,這裡說說一個常見的php notice錯誤。

PHP Notice: curl_setopt(): CURLOPT_SSL_VERIFYHOST with value 1 is deprecated and will be removed as of libcurl 7.28.1. It is recommended to use value 2 instead in XXXXX

看到這個錯誤,未免心裡猛地一驚:這是又改啥啦?

雖然平時線上産品會把這類報錯遮罩掉,不太影響運行,但老這麽報下去實在影響性能。觀察代碼,原來是這一段引起的提示錯誤:

// 這裡假設: $curl_handler是已經聲明好的curl句柄
curl_setopt($curl_handler, CURLOPT_SSL_VERIFYHOST, true);

把上述代碼的第三個bool類型參數true改成2,即可解決報錯:

curl_setopt($curl_handler, CURLOPT_SSL_VERIFYHOST, 2);


閲完此文,您的感想如何?
  • 有用

    0

  • 沒用

    0

  • 開心

    0

  • 憤怒

    0

  • 可憐

    0

1.如文章侵犯了您的版權,請發郵件通知本站,該文章將在24小時内刪除;
2.本站標注原創的文章,轉發時煩請注明來源;
3.交流群: 2702237 13835667

相關課文
  • mac開發接入微信公衆號接口返回報錯 cURL error 56: SSLRead() return error -9806

  • PHP的換行符是什麽

  • pecl安裝程序時報錯Array and string offset access syntax with curly braces is no longer supported

  • 由於商家傳入的H5交易參數有誤,該筆交易暫時無法完成,請聯繫商家解決

我要說說
網上賓友點評