程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> 隨機頭像PHP版

隨機頭像PHP版

編輯:關於PHP編程


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

?>

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved