1.将以下代码存为一个php文件,假定img.php [php] <?php $url='face'; $files=array(); if ($handle=opendir("$url")) { while(false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { if(substr($file,-3)=='png' || substr($file,-3)=='jpg') $files[count($files)] = $file; } } } closedir($handle); $random=rand(0,count($files)-1); readfile("$url/$files[$random]"); ?> [/php] 2.新建一个face文件夹,将所有头像放在……