哪位大神幫我看下呀,我字符類型也定義了,ob_clear();也加了,但是驗(yàn)證碼就是出不來
這個(gè)是image.func.php <?phprequire_once?'include.php';require_once?'string.func.php';/**?*??通過GD庫創(chuàng)建驗(yàn)證碼?*??$width:?驗(yàn)證碼圖片寬度?*??$height:?驗(yàn)證碼圖片高度?*??$type:???產(chǎn)生字符類型,1為數(shù)字,2為數(shù)字和小寫字母,3為數(shù)字小寫字母加大寫字母?*??$length:?驗(yàn)證碼字符個(gè)數(shù)?*??$pixel:?干擾點(diǎn)數(shù)量?*??$line:?干擾線數(shù)量?*??$sess_name:?session?key?*/function?verifyImage($type?=?3,?$length?=?4,?$pixel?=?0,?$line?=?0,?$width?=160,?$height?=?60,?$sess_name?=?"verify"){????//使能session????session_start();????//?創(chuàng)建畫布????//?創(chuàng)建真色彩畫布????$image?=?imagecreatetruecolor($width,?$height);????//?畫筆顏色????$white?=?imagecolorallocate($image,?255,?255,?255);????$black?=?imagecolorallocate($image,?0,?0,?0);????????//用填充矩形填充畫布????imagefilledrectangle($image,?1,?1,?$width-2,?$height-2,?$white);????//?產(chǎn)生隨機(jī)字符串????$chars?=?buidRandomString($type,?$length);????//?echo?$chars."<br>";????//存儲(chǔ)到session????$_SESSION[$sess_name]?=?$chars;????//?字體數(shù)組????$fontfiles?=?array("AHRONBD.TTF","ANDLSO.TTF","ANGSA.TTF","ANGSAB.TTF");????//?隨機(jī)獲取數(shù)組中任意一個(gè)值????$fontfile?=?"../fonts/".$fontfiles[mt_rand(0,?count($fontfiles)-1)];????????????/*?將TTF?(TrueType?Fonts)?字型文字寫入圖片*/????????for?($i=0;?$i?<?$length;?$i++)?{????????//產(chǎn)生14?~?18的隨機(jī)數(shù)用于字體大小????????$size?=?mt_rand(14,?18);????????//產(chǎn)生隨機(jī)數(shù)用于字符角度????????$angle?=?mt_rand(-15,?15);????????//產(chǎn)生字符位置坐標(biāo)????????$x?=?5?+?$i?*?$size;????????$y?=?mt_rand(15,?20);????????????????//?產(chǎn)生隨機(jī)畫筆顏色,用于設(shè)置字體顏色????????$color?=?imagecolorallocate($image,?mt_rand(50,?90),?mt_rand(80,?200),?mt_rand(90,?180));????????$text?=?substr($chars,?$i,?1);????????????????imagettftext($image,?$size,?$angle,?$x,?$y,?$color,?$fontfile,?$text);????????????}????//?繪制點(diǎn)、線等干擾元素????????if?($pixel)?{????????for?($i=0;?$i?<?$pixel;?$i++)?{????????????imagesetpixel($image,?mt_rand(0,?$width-1),?mt_rand(0,?$height-1),?$black);????????}????}????????if?($line)?{????????for?($i=0;?$i?<?$line;?$i++)?{????????????$color?=?imagecolorallocate($image,?mt_rand(50,?90),?mt_rand(80,?200),?mt_rand(90,?180));????????????imageline($image,?mt_rand(0,?$width-1),?mt_rand(0,?$height-1),?mt_rand(0,?$width-1),?mt_rand(0,?$height-1),?$color);????????}????}????????//?輸出圖片格式????ob_clean();????header("content-type:image/gif");????//?生成圖片????imagegif($image);????//?釋放資源????imagedestroy($image);????}verifyImage(2,?4,?10,?3);
這個(gè)是string的
<?php//?產(chǎn)生隨機(jī)數(shù)function?buidRandomString($type=1,?$length?=?4){????????//?根據(jù)參數(shù)類型,產(chǎn)生數(shù)字、數(shù)字小寫字母、數(shù)字小寫字母大寫字母等字符????if?($type?==?1)?{????????$chars?=?join("",?range(0,?9));????}elseif?($type?==?2)?{????????$chars?=?join("",?array_merge(range("a","z"),?range("A",?"Z")));????}elseif?($type?==?3)?{????????$chars?=?join("",?array_merge(range("a","z"),?range("A",?"Z"),?range(0,?9)));????}????????if?($length?>?strlen($chars))?{????????exit("字符串長(zhǎng)度不夠");????}????//?隨機(jī)地打亂字符串中的所有字符????$chars?=?str_shuffle($chars);????//?截取制定長(zhǎng)度字符????return?substr($chars,?0,?$length);????}
這個(gè)是include 的
<?phpheader("content-type:text/html;charset=utf-8");date_default_timezone_set("PRC");//session_start();define("ROOT",?dirname(__FILE__));set_include_path(PATH_SEPARATOR.ROOT."/lib".PATH_SEPARATOR.ROOT."/core".PATH_SEPARATOR.ROOT."/configs".PATH_SEPARATOR.get_include_path());//require_once?'mysql.func.php';require_once?'string.func.php';require_once?'image.func.php';/*require_once?'common.func.php';?require_once?'page.func.php';?require_once?'configs.php';?require_once?'admin.inc.php';?require_once?'cate.inc.php';?require_once?'pro.inc.php';*///?require_once?'album.inc.php';//?require_once?'upload.func.php';//?require_once?'user.inc.php';//?connect();//?連接數(shù)據(jù)庫//$link?=?connet();
畫布和干擾能顯示出來,但是字符串出不來。。,哪位大神幫我看下