The purpose of the verification code is not much to say, before also wrote an article about PHP verification code, but not encapsulated into a class. A code class for PHP is described below.
Codes = Implode (", Array_slice ($codeArray, 0,4)); } public Function createimg () {$_session[' check_pic '] = $this->codes; $img = Imagecreate (70,25); Imagecolorallocate ($img, 222,222,222); $testcolor 1 = imagecolorallocate ($img, 255,0,0); $testcolor 2 = imagecolorallocate ($img, 51,51,51); $testcolor 3 = imagecolorallocate ($img, 0,0,255); $testcolor 4 = imagecolorallocate ($img, 255,0,255); for ($i = 0; $i < 4; $i + +) {imagestring ($img, Rand (5,6), 8 + $i * 15,rand (2,8), $this->codes [$i],rand (1,4)); } imagegif ($IMG); }} $code = new Securitycode (); $code->createimg (); $code = NULL;? >
After encapsulation into a class, the constructor is added, which makes it easier to use. You can also continue to refine the verification code class, such as adding destructors, how to save memory and so on.
http://www.bkjia.com/PHPjc/752568.html www.bkjia.com true http://www.bkjia.com/PHPjc/752568.html techarticle The purpose of the verification code is not much to say, before also wrote an article about PHP verification code, but not encapsulated into a class. Here is a PHP code class. php session_s ...