当前位置:Gxlcms > PHP教程 > php获取bing每日壁纸示例分享_PHP

php获取bing每日壁纸示例分享_PHP

时间:2021-07-01 10:21:17 帮助过:2人阅读

代码如下:
$str=file_get_contents('http://cn.bing.com/HPImageArchive.aspx?idx=0&n=1');
if(preg_match("/(.+?)<\/url>/ies",$str,$matches)){
$imgurl='http://cn.bing.com'.$matches[1];
}
if($imgurl){
header('Content-Type: image/JPEG');
@ob_end_clean();
@readfile($imgurl);
@flush(); @ob_flush();
exit();
}else{
exit('error');
}
?>

人气教程排行