| 
 
     
- UID
 - 40 
 - 帖子
 - 2796 
 - 精华
 - 0 
 - 金钱
 - 5024 点 
 - 阅读权限
 - 200 
 - 在线时间
 - 1313 小时 
 - 注册时间
 - 2009-5-12 
 
  | 
为这个文件起个名字: randimage.php 
 
代码如下:- <?php
 
 - $dir = “images/”;//图片目录,注意是按照名字排序显示的…
 
 - $imgwidth = 0;//图片宽度,为0则为原始大小
 
 - $iforder = 1;//顺序显示还是随机显示,1为顺序显示,0为随机显示
 
 - $ifcircle = 0;//顺序显示的时候是否循环播放,1为循环播放,0为不循环
 
 - session_start();
 
 - if($imgwidth==0){$imgwidth==”";}else{$imgwidth==”width=’”.$imgwidth.”‘”;}
 
 - $handle=opendir($dir);
 
 - while ($file_name=readdir($handle)){
 
 - if(($file_name!==”.”)&&($file_name!==”..”)){$file_list[]=$file_name; }
 
 - }
 
 - closedir($handle);
 
 - if($iforder==1){
 
 - if(isset($_SESSION['sess_order'])){
 
 - if($_SESSION['sess_order']<count($file_list)-1){
 
 - $_SESSION['sess_order'] ;
 
 - }else{
 
 - if($ifcircle == 1){
 
 - $_SESSION['sess_order']=0;
 
 - }
 
 - }
 
 - }else{
 
 - $_SESSION['sess_order']=0;
 
 - }
 
 - $i=$_SESSION['sess_order'];
 
 - }else{
 
 - $num=count($file_list)-1;
 
 - $i=rand(0,$num);
 
 - }
 
 - readfile($dir.$file_list[$i]);
 
 - ?>
 
  复制代码 调用方式:- <img src=”randimage.php” border=”0″>
 
  复制代码 |   
 
 
 
 |