I am a beginner in the use of PHP classes. I have found a class on the Internet that generates verification codes, how can I output the verification code generated by the class where the verification code needs to be output? The code in the class is as follows: & lt ;? Php & nbsp; classAuthCode & nbsp; {& nbsp; var $ image; & nbsp; var $ sBgcolor; & PHP class usage
I am a newbie. I just got started with the concept of class. now I have found a verification code generation class on the internet. how can I output the verification code generated in the class where I need to output the verification code? The code in the class is as follows:
Class AuthCode
{
Var $ image;
Var $ sBgcolor;
Var $ nWidth;
Var $ nHeight;
Var $ nLen;
Var $ bNoise;
Var $ nNoise;
Var $ bBorder;
Var $ aFontlist;
Function AuthCode ()
{
$ This-> sBgcolor = "# FFFFFF ";
$ This-> nWidth = 70;
$ This-> nHeight = 25;
$ This-> nLeftMargin = 5;
$ This-> nRightMargin = 5;
$ This-> nTopMargin = 3;
$ This-> nBottomMargin = 2;
$ This-> nLen = 4;
$ This-> bNoise = true;
$ This-> nNoisePoint = 50;
$ This-> nNoiseLine = 5;
$ This-> bBorder = true;
$ This-> aFontlist = "arial. ttf ";
}
Function OutputImg ()
{
$ This-> image = "";
$ This-> image = imagecreate ($ this-> nWidth, $ this-> nHeight );
$ Back = $ this-> getcolor ($ this-> sBgcolor );
Imagefilledrectangle ($ this-> image, 0, 0, $ this-> nWidth, $ this-> nHeight, $ back );
$ Size = ($ this-> nWidth-$ this-> nLeftMargin-$ this-> nRightMargin)/$ this-> nLen;
If ($ size> ($ this-> nHeight-$ this-> nTopMargin-$ this-> nBottomMargin ))
$ Size = $ this-> nHeight-$ this-> nTopMargin-$ this-> nBottomMargin;
$ Left = ($ this-> nWidth-$ this-> nLen * ($ size + $ size/10)/2 + $ this-> nLeftMargin;
$ Code = "";
For ($ I = 0; $ I <$ this-> nLen; $ I ++)
{
$ Randtext = rand (0, 9 );
$ Code. = $ randtext;
$ TextColor = imagecolorallocate ($ this-> image, rand (0,100), rand (0,100), rand (0,100 ));
$ Font = $ this-> aFontlist;
$ Randsize = rand ($ size-$ size/10, $ size + $ size/10 );
$ Location = $ left + ($ I * $ size + $ size/10 );
Imagettftext ($ this-> image, $ randsize, rand (-18, 18), $ location, rand ($ size, $ size + $ size/5) + $ this-> nTopMargin, $ textColor, $ font, $ randtext );
}
If ($ this-> bNoise = true) $ this-> setnoise ();
$ _ SESSION ['yzm'] = md5 ($ code );
$ Bordercolor = $ this-> getcolor ("# FFFFFF ");
If ($ this-> bBorder = true) imagerectangle ($ this-> image, 0, 0, $ this-> nWidth-1, $ this-> nHeight-1, $ bordercolor );
Header ("Content-type: image/png ");
Imagepng ($ this-> image );
Imagedestroy ($ this-> image );
}
Function setnoise () // sets the noise.
{
For ($ I = 0; $ I <$ this-> nNoiseLine; $ I ++ ){
$ RandColor = imagecolorallocate ($ this-> image, rand (0,255), rand (0,255), rand (0,255 ));
Imageline ($ this-> image, rand (0, $ this-> nWidth), rand (0, $ this-> nHeight), rand (0, $ this-> nWidth), rand (0, $ this-> nHeight), $ randColor );
}
For ($ I = 0; $ I <$ this-> nNoisePoint; $ I ++ ){
$ RandColor = imagecolorallocate ($ this-> image, rand (0,255), rand (0,255), rand (0,255 ));
Imagesetpixel ($ this-> image, rand (0, $ this-> nWidth), rand (0, $ this-> nHeight), $ randColor );