A addition/subtraction verification code written by myself within 10-PHP source code

Source: Internet
Author: User
A addition/subtraction verification code of less than 10 written by yourself, a addition/subtraction verification code of less than 10 written by yourself

 Jiashu = rand (1, 10); $ this-> JianShu = rand (1, 10); $ this-> YunSuan = $ this-> Jiashu> $ this-> JianShu? '-': '+'; $ This-> DeShu = $ this-> Jiashu> $ this-> JianShu? $ This-> Jiashu-$ this-> JianShu: $ this-> Jiashu + $ this-> JianShu;} public function Show ($ W = 100, $ H = 50, $ T = 'Num. ttf', $ Code = 'code') {$ this-> JiaShu (); $ this-> String = $ this-> Jiashu. $ this-> YunSuan. $ this-> JianShu. '=? '; $ This-> Width = $ W; $ this-> Height = $ H; $ this-> Ttf = $ T; $ this-> Session = $ Code; session_start (); $ _ SESSION [$ this-> Session] = $ this-> DeShu; $ this-> Images ();} private function Images () {$ this-> Img = imagecreate ($ this-> Width, $ this-> Height); $ background_color = imagecolorallocate ($ this-> Img, 255,255,255 ); imagecolortransparent ($ this-> Img, $ background_color); imagettftext ($ this-> Img, 14, 0, 1, 20, imagecolorallocate ($ this-> Img, 0, 0, 0), $ this-> Ttf, $ this-> String); $ this-> EchoImages ();} private function EchoImages () {imagepng ($ this-> Img ); imagedestroy ($ this-> Img) ;}$ ImageCode = new ImageCode; $ ImageCode-> Show (130, 35, 'Num. ttf', 'code ');

The above is the content of a plus/minus verification code written by myself within 10. For more information, see PHP Chinese network (www.php1.cn )!

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.