<?php
/*
 * Created on 2011-7-31
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
 for($i=0;$i<4;$i++){
  $rand.=rand(1,9);
 }
 header("content-type:image/gif");
$b=imagecreate(130,40);//建个图像
imagecolorallocate($b,0,0,0);//设置图像颜色
$color=imagecolorallocate($b,255,255,255);//设置图像字体颜色
for($i=0;$i<3;$i++){
$color2=imagecolorallocate($b,rand(0,255),rand(0,255),rand(0,255));//设置图像随机颜色 $b2=imageline($b,rand(0,100),0,rand(0,255),40,$color2);//设置一个验证码线段
}
for($i=0;$i<200;$i++){
imagesetpixel($b,rand()%130,rand()%40,$color2);//设置验证码的点
}
imagestring($b,4,12,12,$rand,$color);//将字体写如图像中
header("content-type:image/gif");
imagegif($b);//输出这个图像?>
这是我本人模仿教程写的简单验证码,希望大家多多指教!