Simple Hanging 2.5.5 Beta free version of simple PHP validation image generation function

Source: Internet
Author: User
Copy CodeThe code is as follows:


function Yzm ($name, $width, $height) {
Header ("Content-type:image/png");
Srand (Double) microtime () *1000000);//sow a seed that generates random numbers to facilitate the use of random number generation below
Session_Start ();//storing random numbers in session
$_session[$name]= "";
$im = Imagecreate ($width, $height); Make picture background size
$black = Imagecolorallocate ($im, 0,0,0); Set of three Colors
$white = Imagecolorallocate ($im, 255,255,255);
$gray = Imagecolorallocate ($im, 200,200,200);
Imagefill ($im, 0,0, $gray); Using area Fill method, set (0,0)
while (($authnum =rand ()%100000) <10000);
$_session[$name]= $authnum;
Imagestring ($im, 5, 3, $authnum, $black);
for ($i =0; $i <200; $i + +)//Add interfering pixels
{
$randcolor = Imagecolorallocate ($im, Rand (0,255), Rand (0,255), Rand (0,255));
Imagesetpixel ($im, Rand ()%70, Rand ()%30, $randcolor);
}
Imagepng ($im);
Imagedestroy ($im);
}?>


Use the method to create a PHP file into the yzm.php, calling
Call the parameters into this function.

The above introduces the simple hanging 2.5.5 Beta free version of the simple PHP verification image generation function, including the simple hanging 2.5.5 Beta free version of the content, I hope that the PHP tutorial interested friends have helped.

  • Related Article

    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.