Ask for a question about the GP library inside PHP
The GD library is encapsulated into the class, but I don't know where it went wrong,
Please take a look at the time, the younger brother is grateful, thank you
Looking for two days did not find there is wrong, the picture is still not show,
Such as:
(I wrote a form biaodan.php first)
<title>Codetest</title>
(then encapsulates a class vcode.class.php)
Class vcode{
Private $width; Wide
private $height;//High
Private $num; Number
private $code;//Verification Code
Private $img; Resources for images
Construction method, three parameters
function __construct ($width, $height, $num) {
$this->width= $width;
$this->height= $height;
$this->num= $num;
$this->code= $this->gocode ();//Call your own method
}
Gets the verification code for the character to be saved in the server
function GetCode () {
For automatic destruction of image resources
function __destruct () {
Imagedestroy ($this->img);
}
}
(In call class code.php)
Open session
Session_Start ();
Include "vcode.class.php";
Construction method
$vcode = new Vcode (80,25,4);
Save a copy of the validation to the server's own space
$_session= $vcode->getcode ();
The Captcha picture output
$vcode->outimg ();
------to solve the idea----------------------
Create a resource
$this->img=imagecreatetruecolor ($this->width,$ Htis->height);
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service