Code as follows,
The first step is to set the MIME type, output format
Header ("content-type:image/png;");
for ($i =0; $i <4; $i + +)
{
$nmsg. =dechex (Mt_rand (0,15));
}
Echo $nmsg;
Second step to create a blank area
$im =imagecreatetruecolor (200,200);
Step three create imagecolorallocate for image fill color
$blue =imagecolorallocate ($im, 0,102,255);
The fourth step fills the blue with the background
Imagefill ($im, 0,0, $blue);
Fifth Step fill text
$white =imagecolorallocate ($im, 255,255,255);
Imagestring ($im, 5,80,80, $nmsg, $white);
The sixth step first output look at the effect
Imagepng ($im);
Destroy, keep the memory
Imagedestroy ($im);
?>
Reply to discussion (solution)
This is the mistake.
Mainly for the For loop that has a problem, I output a verification code, put $nmsg. =dechex (Mt_rand (0,15)); remove it, it will show a verification code, plus the error
The For loop declares the $NMSG variable before:
$nmsg = "";
/First Step setting MIME type, output format
Header ("content-type:image/png;");
$nmsg = ";
for ($i =0; $i <4; $i + +)
{
$nmsg. =dechex (Mt_rand (0,15));
}
Echo $nmsg;
That's all you can do.
Thank you, great God!