Search code examples
phpphp-curl

PHP curl_exec return


I am using this CURLOPT_RETURNTRANSFER => 1 in my code that's return a result if success.

My question is:

The curl_exec() will return a result if I get a response with status != 200 ? like 400 and a message ? or in this case just FALSE ?


Solution

  • Please read the manual carefuly. The answer is there. https://www.php.net/manual/en/function.curl-exec.php

    Note that response status codes which indicate errors (such as 404 Not found) are not regarded as failure. curl_getinfo() can be used to check for these.