#<?php
session_start();
header("content-type:image/png"); / /Set the format of creating images
$ Image_width = 70; // Set image width
$ Image_height = 18; // Set image height
srand (microtime ()*100000); // Set random number of random numbers Seed
for ($ i = 0; $ i & lt; 4; $ i) {// Cycle output a 4 -bit random number
$ New_number. = Dechex (RAND (0,15));
}
$_SESSION[check_checks]=$new_number; //Write the obtained random number verification code into the SESSION variable
$num_image=imagecreate($image_width,$image_height); //Create a Canvas
imagecolorallocate($num_image,255,255,255); //Set the color of the canvas
for($i=0;$i<strlen($_SESSION[check_checks]);$i ){ //Loop to read SESSION Verification code in variables
$ font = mt_rand (3,5); // Set random fonts
$ x = mt_rand (1,8) $ image_width*$ I/4; // Set the random characters. X coordinate of the position
$y=mt_rand(1,$image_height/4); //Set the Y coordinate of the position of the random character
$color=imagecolorallocate($num_image,mt_rand(0,100),mt_rand(0,150) ,mt_rand(0,200)); //Set the color of characters
imagestring($num_image,$font,$x,$y,$_SESSION[check_checks][$i],$color); //Output characters horizontally
}
imagepng($num_image); using using PNG using PNG format ’ ’ ‐ ’ s ’ s ‐ ‐ ‐ ‐ ‐ ‐ use to use PNG to PNG to use PNG format’s ’ s to use PNG format--
There are many errors in your code.
Comment out header("content-type:image/png"); first and deal with the error first.
Generally, the header is set above the imagepng() function that generates images, so that errors can be easily adjusted.