在生成圖片驗證碼的時候有這么一段代碼:
//打印出隨機數
//dechex — 十進制轉換為十六進制0-9 a-f
//創建一個4位的驗證碼
header('Content-Type:image/png');
$a='';
for ($i=0;$i<4;$i++){
$a.=dechex(mt_rand(0, 15));
}
$im=imagecreatetruecolor(75, 20);
$blue=imagecolorallocate($im, 0, 0, 255);
$white=imagecolorallocate($im, 255, 255, 255);
imagefill($im, 0, 0, $blue);
imagestring($im, 10, 0, 0, $a, $white);
imagepng($im);
imagedestroy($im);
當時沒有定義$a,然后就怎么都出不來圖片。當時自己想了很多辦法。問了很多人,有說要開gb2擴展的,有說可能附帶了bom頭的,去掉bom頭。這次出問題,倒是讓我認識了很多新的名詞。下次再遇到要好好注意一下。