<?php
/* Set Artboard size */
$width = 130;
$height = 60;
/* Create a new True color image */
$img = Imagecreatetruecolor ($width, $height);
/* Predefined color value range */
$ranColor = Imagecolorallocate ($img, Rand (0,255), Rand (0,255), Rand (0,255));
$white = Imagecolorallocate ($img, 255,255,255);
Draw a rectangle with the same capitalization overrides the default background (black) Universal White
Imagefilledrectangle ($img, 0,0,130,60, $white);
Create an array of characters to be drawn
$str = "abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ123456789";
$str _array = "";
for ($i = 0; $i < 5; $i + +) {//control requires several characters
$str _array = $str _array. $str [Rand (0,strlen ($STR)-1)];
}
/* Custom Font tilt */
Imagettftext ($img, 30,rand ( -7,7), 0,50, $ranColor, ' Calibri.ttf ', $str _array);
/* Randomly draw snowflakes */
for ($i = 0; $i < $i + +) {
Imagesetpixel ($img, Rand (0,130), Rand (0,60), $ranColor);
}
/* Set line width */
Imagesetthickness ($img, 2);
/* Random Dash */
for ($m =0; $m <5; $m + +) {
Imageline ($img, Rand (0,130), Rand (0,60), Rand (0,130), Rand (0,60), $ranColor);
}
Header (' content-type:image/gif ');
/* Output images to a browser or file in GIF format */
Imagegif ($IMG);
/* Destroy image Release Memory */imagedestroy ($IMG);
?>
PHP Verification Code Drawing