PHP development verification code tutorial: Create canvas and output
In the previous chapter, when we created the canvas, we wrote the width and height of the image directly in the function, which would be more troublesome to modify.
Let's look at the following piece of code:
<?php //创建一个画布 $width = 85; $height = 30; $img = imagecreatetruecolor($width, $height); //输出图像 header("content-type:image/png"); imagepng($img); //销毁资源 imagedestroy($img); ?>
With the above code, we can also output a canvas with a black background, width 85, and height 30