隨機頭像PHP版
更新時間:2006年10月09日 00:00:00 作者:
1. 31字節(jié) 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]");
?>
相關文章
創(chuàng)造世界上最簡單的 PHP 開發(fā)模式
這篇文章主要介紹了創(chuàng)造世界上最簡單的 PHP 開發(fā)模式2006-12-12php中將指針移動到數(shù)據(jù)集初始位置的實現(xiàn)代碼[mysql_data_seek]
在php中我們要返回數(shù)據(jù)集初始位置mysql_data_seek函數(shù)即可實現(xiàn),下面看代碼2012-11-11