如果希望php訪問一下網址,但不需要返回結果,如:需要執行很長時間的頁面,不用等待返回結果,只需要執行了就可以了,辦法之一:
使用CURL需要設置CUROPT_TIMEOUT為1(最小為1)。也就是說,客戶端至少必須等待1秒鍾。
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); }