分类广告


推荐文章

  • 没有找到任何内容!
您当前的位置:中国站长下载网络编程PHP专区 → 文章内容

随机头像PHP版

  • 作者:佚名    来源:不详    发布时间:2006-2-26 1:52:43
  • 字体大小:

1.  31字节 PHP 随机显示头像 
<?readfile(rand(0,5).'.jpg');?>



2.
<?php

$url='pic';
//图片地址,用相对路径

$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]");

?>
<
上一篇3.从实例开始 下一篇1.PHP简介