|
一、显示效果

二、代码如下
[U]复制代码[/U] 代码如下:/*
* @Author fy
*/
$; //图片宽度
$; //图片高度
$codelen =4; //验证码长度
$fontsize =20; //字体大小
$charset = 'abcdefghkmnprstuvwxyzABCDEFGHKMNPRSTUVWXYZ23456789';
$font = 'Fonts/segoesc.ttf';
$im=imagecreatetruecolor($,$);
$while=imageColorAllocate($im,255,255,255);
imagefill($im,0,0,$while); //填充图像
//取得字符串
$authstr='';
$_len = strlen($charset)-1;
for ($i=0;$i
session_start();
$_SESSION['scode']=strtolower($authstr);//全部转为小写,主要是为了不区分大小写
//随机画点,已经改为划星星了
for ($i=0;$i
$_x=intval($$codelen); //计算字符距离
$_y=intval($*0.7); //字符显示在图片70%的位置
for($i=0;$i
$randcolor=imagecolorallocate($im,mt_rand(0,150),mt_rand(0,150),mt_rand(0,150));
//imagestring($im,5,$j,5,$[$i],$color3);
// imagettftext ( resource $image , float $size , float $angle , int $x , int $y , int $color , string $fontfile , string $text )
imagettftext($im,$fontsize,mt_rand(-30,30),$i*$_x+3,$_y,$randcolor,$font,$authstr[$i]);
}
//生成图像
header("content-type:image/PNG");
imagePNG($im);
imageDestroy($im);
您可能感兴趣的文章:php图片验证码代码php5 图片验证码实现代码PHP图片验证码制作实现分享(全)PHP生成Gif图片验证码PHP生成图片验证码、点击切换实例php生成图片验证码-附五种验证码PHP编写的图片验证码类文件分享
|
|