Workaround for the PHP curl_exec function to return false

Source: Internet
Author: User
Tags php server
Knowing the PHP curl_exec function, it is the execution of a given curl session. Returns TRUE if successful, or FALSE on failure.

Sometimes when PHP uses Curl requests, the page is blank and nothing is output. Debug Discovery Returns the result: false, what should I do if I encounter this situation? This article describes the workaround when the PHP curl_exec function returns false

We use examples to give you a demonstration, I believe you will see more clearly.

The first is an example of a curl request;

Request return result: false;

debugging, typing curl error number; Tip: Problem (2) in the chunked-encoded data

Workaround:

In

$output = curl_exec ($CURLP);

Before adding the following paragraph:

curl_setopt ($CURLP, curlopt_http_version, CURL_HTTP_VERSION_1_0);

The meaning of this passage is:

curl_setopt-Set a curl transfer option.

For details, refer to the curl_setopt () function in the Curl function of the PHP manual

Run again and find that the curl request returned a normal result.

"Related articles recommended"

Example of usage of 1.PHP curl_exec function

2. Share a workaround when PHP server does not support PHP curl_exec functions

3. PHP curl_exec function to get the output information of Curl request

4. PHP curl_exec () function curl Gets the return value of the method

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.