Three PHP kanji English validation Code generation Program (_php) tutorial

Source: Internet
Author: User
Three PHP tutorials Chinese characters English validation code generation program

$ChineseChar = Explode (', ', "People, out, come, friends, learning, filial piety, benevolence, righteousness, propriety, low, loyal, state, medium, easy, white, person, fire, king, Gold, wood, thunder, Wind, dragon, Tiger, day, ground, birth, halo, Dish, bird, field, three, hundred, money, blessing, love, affection, beast, insect, fish, nine, net, New, degrees, Ay, alas, Ah, oh, Miriam, old, Little, day, month, star, Ken, each, Cheng ");
$k [0]= $ChineseChar [Array_rand ($ChineseChar)];
$k [1]= $ChineseChar [Array_rand ($ChineseChar)];
$k [2]= $ChineseChar [Array_rand ($ChineseChar)];
$k [3]= $ChineseChar [Array_rand ($ChineseChar)];
$cookie _str=implode (' ', $k);
Setcookie (' Vrify ', MD5 ($cookie _str), Time () +600);
$str [0]=iconv (' gb2312 ', ' UTF-8 ', $k [0]);
$str [1]=iconv (' gb2312 ', ' UTF-8 ', $k [1]);
$str [2]=iconv (' gb2312 ', ' UTF-8 ', $k [2]);
$str [3]=iconv (' gb2312 ', ' UTF-8 ', $k [3]);
Constructing images
$x _size=100;
$y _size=25;
$font = ' Simhei.ttf ';
$pic =imagecreate ($x _size, $y _size);
$background _color = imagecolorallocate ($pic, 255, 255, 255);
$FOREGROUNDARR = Array (imagecolorallocate ($pic, rand (0,), rand (0,), rand (0, 20)),
Imagecolorallocate ($pic, rand (0,), rand (0, 245, 255)),
Imagecolorallocate ($pic, rand (245, 255), rand (0,), rand (0, 10)),
Imagecolorallocate ($pic, rand (245, 255), rand (0,), rand (245, 255)));
Imagettftext ($pic, Mt_rand (12,15), Mt_rand ( -8,8), 6,mt_rand (19,22), $foregroundArr [Rand (0,3)], $font, $str [0]);
Imagettftext ($pic, Mt_rand (15,17), Mt_rand ( -8,8), 26,20, $foregroundArr [rand (0,3)], $font, $str [1]);
Imagettftext ($pic, Mt_rand (12,15), Mt_rand ( -8,8), 46,20, $foregroundArr [rand (0,3)], $font, $str [2]);
Imagettftext ($pic, Mt_rand (15,17), Mt_rand ( -8,8), 66,mt_rand (19,22), $foregroundArr [Rand (0,3)], $font, $str [3]);
for ($i =0; $i <80; $i + +)
{
$pointcol = Imagecolorallocate ($pic, Rand (0,255), Rand (0,255), Rand (0,255));
Imagesetpixel ($pic, rand (2, $x _size-2), rand (2, $y _size-2), $pointcol);
}
$border = Imagecolorallocate ($pic, 133, 153, 193);
Imagerectangle ($pic, 0, 0, $x _size-1, $y _size-1, $border);
Imagepng ($pic);
Imagedestroy ($pic);
?>

1 2 3 4

http://www.bkjia.com/PHPjc/444920.html www.bkjia.com true http://www.bkjia.com/PHPjc/444920.html techarticle Three PHP tutorials Chinese English validation code generator $ChineseChar = Explode (', ', people, out, come, friends, learn, filial piety, benevolence, righteousness, ritual, low, loyal, Kingdom, Medium, easy, white, fire, king, Gold, wood, thunder, Wind, Dragon, Tiger, Sky, land ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.