手机
当前位置:查字典教程网 >编程开发 >php教程 >随机头像PHP版
随机头像PHP版
摘要:1.31字节PHP随机显示头像2.

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版】相关文章:

php从文件夹随机读取文件的方法

php序列化函数serialize() 和 unserialize() 与原生函数对比

php数组随机排序实现方法

多重條件組合查詢(一)

PHP邮件专题

无数据库的详细域名查询程序PHP版(4)

PHP动态图像的创建

开发大型PHP项目的方法

论坛头像随机变换代码

虚拟主机中对PHP的特殊设置

上一篇: 1.PHP简介
精品推荐
分类导航