php curl implementation method without waiting for return

藏色散人
Release: 2023-03-06 11:30:02
Original
4051 people have browsed it

In PHP, you can set "CUROPT_TIMEOUT" to 1 when using CURL to trigger PHP curl without waiting for return.

php curl implementation method without waiting for return

Recommendation: "PHP Video Tutorial"

php curl

method to trigger a script without waiting for return

If you want PHP to access a URL, but do not need to return a result, such as a page that needs to be executed for a long time, you do not need to wait for the return result, you only need to execute it. One of the methods:

Use CURL needs to set CUROPT_TIMEOUT to 1 (minimum is 1). That is, the client must wait at least 1 second.

public function set_cache_log(){
        $host = "https://****.com.cn/index.php?s=/moudle/controller/function/id/12";
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $host);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_TIMEOUT, 1);
        $content=curl_exec($ch);
        curl_close($ch);
    }
Copy after login

The above is the detailed content of php curl implementation method without waiting for return. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template