Perfect solution thinkphp Verification Code error cannot be displayed method, thinkphp captcha _php Tutorial

Source: Internet
Author: User

Perfect solution thinkphp Verification Code error cannot display the method, thinkphp verification code


This article describes a perfect solution to the thinkphp verification code error cannot be displayed method. Share to everyone for your reference. The specific analysis is as follows:

Today to do verification code this piece, think of TP comes with the verification picture, Exultation, but Tinker half a day not come out, has been a small x look.

The official tips are as follows:
If the verification code cannot be displayed, please check:
①php has installed GD library support;
② outputs before output (especially UTF8 BOM header information output);
Whether the ③image class library is imported correctly;
④ If it is a Chinese code check if there is a copy font file to the directory where the library is located;

But a half-day test, no! Online to find a usable method, put in a file to execute the available, into the TP inside through the index.php entrance is a small x, and then can use the method where the file to change the code to utf-8 containing BOM code will also appear small x, other codes will come out of the verification code, The preliminary judgment is that TP executes to the output verification code before the content output, the supervisor thought of the output before the removal of the line.

Similar:
Copy the Code code as follows: <?php
Ob_start ();//Do not add this is not possible (seemingly do not add)
echo "Do not show";
Ob_end_clean ();
echo "just show this";
?>
Workaround, modify the Generate Captcha method:
Copy Code code as follows://Generate Verification code
Public Function verifyimg () {
Import ("ORG. Util.image ");
Ob_end_clean ();
Image::buildimageverify ();
}

It is hoped that this article is helpful to the PHP program design based on thinkphp framework.

http://www.bkjia.com/PHPjc/924542.html www.bkjia.com true http://www.bkjia.com/PHPjc/924542.html techarticle Perfect Solution thinkphp Verification Code error can not be displayed method, thinkphp verification Code This article describes the perfect solution thinkphp CAPTCHA error can not be displayed method. Share for everyone to join us ...

  • 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.