?看評(píng)論區(qū)說(shuō)沒(méi)加session_start();但是在php文件中加了session_start()還是出現(xiàn)錯(cuò)誤<?php?? ?session_start();//1.創(chuàng)建畫布? ?$image = imagecreatetruecolor(100, 30);//創(chuàng)建一個(gè)高100寬30的畫布(默認(rèn)背景是黑色)? ?$bgcolor = imagecolorallocate($image, 255, 255, 255);//#fff ?imagecolorallocate為圖像分配顏色? ?imagefill($image, 0, 0, $bgcolor);//區(qū)域填充?? ?// 2.實(shí)現(xiàn)數(shù)字加字母驗(yàn)證碼(二)? ?$captch_code = '';? ?for($i=0;$i<4;$i++){? ? ?$fontsize = 6;? ? ?$fontcolor = imagecolorallocate($image, rand(0,120), rand(0,120), rand(0,120));? ? ?$data = '123456789';? ? ?$fontcontent = substr($data, rand(0,strlen($data)-1),1);? ? ?$captch_code.=$fontcontent;? ? ?$x = ($i*100/4) + rand(5,10);? ? ?$y = rand(5,10);? ? ?imagestring($image, $fontsize, $x, $y, $fontcontent, $fontcolor);? ?}? ?$_SEESSION['authcode']=$captch_code;//3.增加干擾元素? ?//增加點(diǎn)干擾? ?for ($i=0; $i < 200; $i++) {?? ? ?$pointcolor = imagecolorallocate($image, rand(50,200), rand(50,200), rand(50,200));? ? ?imagesetpixel($image, rand(1,99), rand(1,29), $pointcolor);? ?}? ?//增加線干擾? ?for ($i=0; $i < 3; $i++) {?? ? ?$linecolor = imagecolorallocate($image, rand(80,220), rand(80,220), rand(80,220));? ? ?imageline($image, rand(1,99), rand(1,29), rand(1,99), rand(1,29), $linecolor);? ?}? ?header('content-type:image/png');//向?yàn)g覽器輸出圖片頭信息? ?imagepng($image);//輸出圖片到瀏覽器? ?//end? ?imagedestroy($image);//銷毀圖片
查看完整描述