盾怪网教程:是一个免费提供流行杀毒软件教程、在线学习分享的学习平台!

随机头像PHP版

时间:2024/11/21作者:未知来源:盾怪网教程人气:

[摘要]1. 31字节 PHP 随机显示头像 <?readfile(rand(0,5).'.jpg');?>2.<?phpurl='pic';//图片地址...

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版




Copyright © 2012-2018 盾怪网教程(http://www.dunguai.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版