<?php
$arr =
array("A","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","Q","r","s","t","u","V","w","x","Y","z","0","1","2","3","4","5","6","7","8","9");
$r
= "";
for($i=1;$i<=4;$i++){
$r.= $arr[rand(0,count($arr)-1)];
echo $r;
}
//生成图片
$img = imagecreatetruecolor(100,50);
//背景颜色
$background =
imagecolorallocate($img,2,6,8);
//字体颜色
$color =
imagecolorallocate($img,200,233,255);
//图片上生成文字
imagestring($img,5,30,20,"$r",$color);
//把php当成图片输出,必须给图片一个头声明
ob_clean();
header("content-type:image/gif");
//最终生成图片
imagegif($img);
?>
原文地址:http://www.cnblogs.com/ZH1132672711/p/3726716.html