当前位置:Gxlcms > PHP教程 > 代码-php怎么将验证码返回给androin?

代码-php怎么将验证码返回给androin?

时间:2021-07-01 10:21:17 帮助过:6人阅读

代码验证码phpandroid

php生成验证码及图片的代码如下:

header('Content-type:image/png');
require_once './function.php';
$width=65;
$height=20;
$image=imagecreate($width,$height);

$bg_color=imagecolorallocate($image,0x33,0x66,0xFF);
imagefilledrectangle($image,0,0,$width,$height,$bg_color);
$text=random(5);
$font=5;
$x=imagesx($image)/2-strlen($text)*imagefontwidth($font)/2;
$y=imagesy($image)/2-imagefontheight($font)/2;

$fg_color=imagecolorallocate($image,0xFF,0xFF,0xFF);
imagestring($image,$font,$x,$y,$text,$fg_color);

$_COOKIE['captcha']=$text;

imagepng($image);
imagedestroy($image);?>

怎么给android啊

人气教程排行