PHP

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.交流群: PHP+JS聊天群

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

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

  • PHP的換行符是什麽

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

我要說說
網上賓友點評