search
  • Sign In
  • Sign Up
Password reset successful

Follow the proiects vou are interested in andi aet the latestnews about them taster

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

new file
<?php //创建一个画布 $width = 85; $height = 30; $img = imagecreatetruecolor($width, $height); //输出图像 header("content-type:image/png"); imagepng($img); //销毁资源 imagedestroy($img); ?>
Reset Code
Automatic operation
submit
Preview Clear