1. <?php   
  2. $url='m';   
  3. $files=array();   
  4. if ($handle=opendir("$url")) {   
  5. while(false !== ($file = readdir($handle))) {   
  6.   if ($file != "." && $file != "..") {   
  7.   if(substr($file,-3)=='gif' || substr($file,-3)=='jpg') $files[count($files)] = $file;   
  8.   }   
  9. }   
  10. }   
  11.  
  12. $randrandom=rand(0,count($files)-1);   
  13. readfile("$url/$files[$random]");   
  14. closedir($handle);   
  15. ?> 

代码释义:$url='m';  图片在M目录

substr($file,-3)=='jpg')  使用3.jpg这个文件夹 这是个文件夹

目录层次 3.jpg/m/图片
index.php即上述代码 与m文件夹同目录

调用的时候 调用 你的域名/3.jpg 即可

源文件下载 http://www.9tu.in/hostloc/shuaxinhuantuxiang-php.zip

本日志由 eben 于 2011-08-25 21:12:04 发表到 开源源码程序 中,目前已经被浏览 234 次,评论 0 次;

作者添加了以下标签: php刷新换图片