PHP 代码延时加载:使用 sleep() 函数实现 10 秒延迟
您可以使用sleep()函数来实现延时加载。具体代码如下所示:
function getydll($url) {
$url = 'https://apistore.aizhan.com/baidurank/siteinfos/79bd537a7e2029d566c8331968512526?domains='.$url;
sleep(10); // 延时10秒
$html = file_get_contents($url);
$url = str_replace('.','\.',addslashes($url));
$search = '/m_ip":"(.*?)"/';
preg_match($search, $html, $Date);
if($Date[1]){
return $Date[1];
}else{
return '0';
}
}
在调用getydll()函数时,会在执行file_get_contents()函数之前延时10秒。
原文地址: https://www.cveoy.top/t/topic/HLc 著作权归作者所有。请勿转载和采集!