php获取bing每日图片
2014-02-20 17:44
337 查看
必应每天都会更新一些漂亮高清的图片,这段代码获取必应每天更新的图片。我们也可以把它作为网站的背景使用。
必应效果 必应地址:http://cn.bing.com/
实际使用后效果 演示地址:http://cs.dzzoffice.com/
以下代码复制存为 .php文件
代码:
必应效果 必应地址:http://cn.bing.com/
实际使用后效果 演示地址:http://cs.dzzoffice.com/
以下代码复制存为 .php文件
代码:
<?php $str=file_get_contents('http://cn.bing.com/HPImageArchive.aspx?idx=0&n=1'); if(preg_match("/<url>(.+?)<\/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'); } ?>
相关文章推荐
- PHP多进程
- SFTP连接工具类
- php自动加载autoload机制示例分享
- php多文件上传下载示例分享
- php函数 之 iconv 不是php的默认函数,也是默认安装的模块。需要安装才能用的。
- php分页代码学习示例分享
- 在yii中使用dropDownlist与listData实现下拉菜单
- commons-ftp中ftpClient类的API(构造方法)
- PHP判断远程图片或文件是否存在
- php跨域cookie共享使用方法
- php图片缩放实现代码
- php多文件上传实现代码
- SFTP连接异常 Could not connect to SFTP server. Connection timed out
- php去除html
- php接口
- php中通过smtp发邮件的类,测试通过
- php开发需要注意什么问题?
- 运行PHP程序时提示“Notice: Undefined index”的解决办法
- yii ajax csrf token not verfied 解决
- php防止刷新重复提交