PHP development verification code tutorial: Create verification code base map
Implementing the verification code base map
Before learning to make the verification code, you can view the manual of the GD library on php.cn for a better understanding. Functions required to create verification codes.
Create a base map of 100, 30 through the imagecreatetruecolor function
header('content-type: image/png');Use the header method of php to output the content in the format of png
imagepeng($image);返回图片 imagedestroy($image);
It is convenient to destroy the image Recycling of system resources
Use imagecolorallocate to make a white filling
$bgcolor = imagecolorallocate($image,255,255,255);//#FFFFFFFFFFFF
Fill it into our base map
imagefill($image,0,0,$bgcolor);
Generates a white base map

The color of the example image has been changed to make it easier for readers to see clearly
<?php
$image = imagecreatetruecolor(100,30);
$bgcolor = imagecolorallocate($image,000,255,255);//#FFFFFFFFFFFF
imagefill($image,0,0,$bgcolor);
header('content-type: image/png');
imagepng($image);
//销毁
imagedestroy($image);
?>Note:
The default output of imagecreatetruecolor is black Background
Before outputting the image, the header information must be output in advance
- Course Recommendations
- Courseware download
The courseware is not available for download at the moment. The staff is currently organizing it. Please pay more attention to this course in the future~ 















