⊗ppSpCrECh 31 of 83 menu

Checking CURL Response for Errors in PHP

If some error occurs during the request, the variable with the result will contain false. This can be used to check for an error:

<?php // Execute the request: $res = curl_exec($curl); if ($res === false) { // Output an error message: echo 'error'; } else { // Output the result: var_dump($res); } ?>

Using the curl_error function, you can get the text of the error that occurred in CURL:

<?php // Execute the request: $res = curl_exec($curl); if ($res === false) { // Output the error: echo curl_error($curl); } else { // Output the result: var_dump($res); } ?>

Make the appropriate corrections in your function.

Try to access a non-existent website. Study the CURL error text for this case.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline