ThinkPHP verification code and paging instance tutorial

Source: Internet
Author: User
This article mainly introduces ThinkPHP verification code and paging instance tutorials, which are common applications in ThinkPHP and are very useful. if you need ThinkPHP, refer to ThinkPHP.

This example describes two common features of ThinkPHP: verification code and paging. ThinkPHP is very common in project development and has high practical value. The complete instance is shared with you for your reference. The details are as follows:

I. verification code:

Import the verification code class. there is a verification code method in aoli \ ThinkPHP \ Lib \ ORG \ Util \ Image. class. php.

1. English verification code:

buildImageVerify($length,$mode,$type,$width,$height,$verifyName)

The parameters are as follows:

Length: the length of the verification code. the default value is 4 digits.
Mode: verify the string type. the default value is a number. other supported types include 0 letters, 1 digits, 2 uppercase letters, 3 lowercase letters, and 4.
Mix Chinese 5 (remove confusing characters oOLl and number 01)
Type: the image type of the verification code. the default value is png.
Width: the verification code width. it is automatically calculated based on the verification code length by default.
Height: the height of the verification code. the default value is 22.
VerifyName: The SESSION record name of the verification code. the default value is verify.

2. Chinese verification code:

GBVerify ($length,$type,$width,$height,$fontface,$verifyName)

The parameters are as follows:

Length: the length of the verification code. the default value is 4 digits.
Type: the image type of the verification code. the default value is png.
Width: the verification code width. it is automatically calculated based on the verification code length by default.
Height: height of the verification code. the default value is 50.
Fontface: the font file used. use the complete file name or put it under the Directory where the image class is located. the default font file used is simhei. ttf (this file can be found in the Fonts directory of the window)
VerifyName: The SESSION record name of the verification code. the default value is verify.

3. if the verification code cannot be displayed, check:

①. Has PHP installed GD library support;
②. Whether there is any output before the output (especially the UTF8 BOM header information output );
③. Whether the Image Class Library is correctly imported;
④. Check whether the font file has been copied to the directory where the class library is located using the Chinese verification code;

4. action:

The CommonAction. class. php page code is as follows:

<? Phpclass CommonAction extends Action {function verify () {import ('org. util. image '); // English verification code // Image: buildImageVerify (5, 5, gif, 90, 30, 'verify'); // Chinese verification code Image :: GBVerify () ;}}?>

5. view template section:

The template index.html page is as follows:

Verification code:

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.