Home  >  Article  >  Backend Development  >  Solution to php curl_exec function returning false

Solution to php curl_exec function returning false

怪我咯
怪我咯Original
2017-05-18 11:40:4819339browse

If you have learned about the php curl_exec function, you know that it executes a given cURL session. Returns TRUE on success or FALSE on failure.

Sometimes when PHP uses curl to request, the page is blank and nothing is output. Debugging found that the return result was: false. How to solve this situation? This article will introduce the solution when the php curl_exec function returns false

We will directly demonstrate it with examples, I believe you will understand it more clearly.

First is a curl request example;

Solution to php curl_exec function returning false

##Request return result: false;

Solution to php curl_exec function returning false

Debugging, type the curl error number; prompt: Problem (2) in the Chunked-Encoded data

Solution to php curl_exec function returning false

Solution to php curl_exec function returning false

Solution:

Add the following paragraph in front of

$output = curl_exec($curlp);

:

curl_setopt($curlp, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);

This paragraph means:

curl_setopt — Set a cURL transport option.

Solution to php curl_exec function returning false

For details, please refer to the curl_setopt() function in the

PHP manual CURL

Solution to php curl_exec function returning false

Run it again and find that the CURL request returns normal results.

Solution to php curl_exec function returning false

【Recommended related articles】

1.

Detailed explanation of usage examples of PHP curl_exec function

2.

Share a solution when the PHP server does not support the php curl_exec function

3.

Get the output information of the CURL request from the php curl_exec function

4.

php curl_exec() function CURL method to get the return value

The above is the detailed content of Solution to php curl_exec function returning false. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn