热门关键字:  PHP  Cisco  seo  网络广告 虚拟主机 中文域名
当前位置 :| 主页>编程开发>PHP>php应用>

PHP随机图片代码

来源:未知 作者:未知 时间:2006-03-26 点击:
<?php

$url='../images'; //图片地址,只可以用./you/images这样的路径

$files=array();
if ($handle=opendir("$url")) {
    while(false !== ($file = readdir($handle))) {
          if ($file != "." && $file != "..") {
          if(substr($file,-3)=='gif' || substr($file,-3)=='jpg') $files[count($files)] = $file;
          }
    }
}
closedir($handle);

$random=rand(0,count($files)-1);
if(substr($files[$random],-3)=='gif') header("Content-type: image/gif");
elseif(substr($files[$random],-3)=='jpg') header("Content-type: image/jpeg");
readfile("$url/$files[$random]");

最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册
赞助商连接