当前位置: 首页 > 图文教程 > 网络编程 > PHP > 随机头像PHP版

PHP
使用无限生命期Session的方法
php+oracle 分页类
用PHP读取IMAP邮件
一段php加密解密的代码
基于qmail的完整WEBMAIL解决方案安装详解
用PHP发电子邮件
PHP网站提速三大“软”招
在线短消息收发的程序,不用数据库
PHP的开合式多级菜单程序
PHP的栏目导航程序
PHP系统流量分析的程序
用php写的serv-u的web申请账号的程序
php中的时间处理
在线竞拍系统的PHP实现框架(二)
用文本作数据处理
PHP 和 MySQL 基础教程(一)
浅谈PHP语法(1)
无数据库的详细域名查询程序PHP版(3)
域名查询代码公布
最省空间的计数器

随机头像PHP版


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 62 ::
收藏到网摘: n/a


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