Collection of a more beautiful PHP verification code class _php tutorial

Source: Internet
Author: User
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 ...

  • Contact Us

    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

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.