0

I'm just wondering, when using cURL and you get the results of the cURL operation via:

$ch = curl_init('www.example.com');
.......
$response = curl_exec($ch);

... and then get the status code via:

$response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);

If the status code returned to $response_code is anything BUT 200 does that mean that curl_exec will always return false?

3
  • Is this code is what exactly which you are using, and please show your code which is in between curl_init and curl_exec Commented Oct 5, 2014 at 8:25
  • No it doesn't, for instance if you get an 301 then you will still get a valid response. Commented Oct 5, 2014 at 8:29
  • @BhaveshGangani The code isn't really relevant which is why I have left it out. Commented Oct 5, 2014 at 8:39

1 Answer 1

1
Curl_exec wont return false if the status code returned is even 200.

As @krister mentioned you will get get a value response(returns the result) if the status code is even 301.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.