
随机头像PHP版
2021-05-25 21:29:001.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]");
?>
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。 如涉及版权问题,请提交至online#300.cn邮箱联系删除。