<?php
header('Content-type:text/html;charset=utf-8');
$img=imagecreatetruecolor(130,40);
$bg = imagecolorallocate($img,mt_rand(200,255),mt_rand(200,255),mt_rand(200,255));
imagefill($img,0,0,$bg);
$str = implode('',array_merge(range('a','z'),range('A','Z'),range(1,9)));
$captcha = '';
for($i = 0,$len = strlen($str);$i < 5;$i++){
$captcha .= $str[mt_rand(0,$len - 1)] . ' ';
}
$str_color = imagecolorallocate($img,mt_rand(1,150),mt_rand(1,150),mt_rand(1,150));
imagestring($img,15,30,15,$captcha,$str_color);
header('content-type:image/png');
imagepng($img);
?>
php 自己写的简单验证码程序
最新推荐文章于 2019-07-25 15:36:30 发布