您的位置:首页 > 编程语言 > PHP开发

PHP生成雪花背景的验证码

2017-01-02 19:12 302 查看
<php

header("Content-type: image/png");

$img_height=80;

$img_width=22;

$im = imagecreate($img_height,$img_width);

$background_color = imagecolorallocate($im, 255, 255, 255);

$text_color = imagecolorallocate($im, 233, 14, 91);

for ($i=1; $i<=100; $i++) {

  imagestring($im,1,mt_rand(1,$img_height),mt_rand(1,$img_width),"*",imagecolorallocate($im,mt_rand(200,255),mt_rand(200,255),mt_rand(200,255)));

}

//$str=mt_rand(1000,9000);

$acceptedChars = '1234567890abcdefghijklmnopqrstuvwxyz';

  $max = strlen($acceptedChars)-1;

   $str="";

  for($i=0; $i < 4; $i++) {

   $str .= $acceptedChars{mt_rand(0, $max)};

   $str.=" ";

  }

imagestring($im, 5,8,3,$str, $text_color);

imagepng($im);

imagedestroy($im);

?>

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: