页面导航: 首页网络编程PHP编程php教程 → 正文内容

随机头像PHP版

发布:dxy 字体:[增加 减小] 类型:转载

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]");
?>
浏览次数:载入中... 打印本文关闭本文文章来源
·在百度中搜索关于“随机头像PHP版相关内容

文章评论

共有 位脚本之家网友发表了评论我来说两句

同 类 文 章
最 近 更 新
热 点 排 行