Thinkphp verification code error cannot be displayed. thinkphp verification code _ PHP Tutorial

Source: Internet
Author: User
Thinkphp verification code is a perfect solution to the problem where thinkphp verification code fails to be displayed. The thinkphp verification code error cannot be displayed. the thinkphp verification code examples in this article describe how to perfectly solve thinkphp verification code error cannot be displayed. I would like to share with you how to handle thinkphp verification code errors that cannot be displayed. thinkphp verification code

This article describes how to perfectly solve thinkphp verification code errors that cannot be displayed. Share it with you for your reference. The specific analysis is as follows:

Today, we are doing the verification code. I think that tp comes with the verification picture. I'm so happy, but it's always a small X.

Official tips:
If the verification code cannot be displayed, check:
① Whether the GD library support has been installed in PHP;
② 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;

But the test lasts for half a day! Find a usable method on the Internet, put it in a file for execution, and enter the tp through index. the php entry is a small x, and then the code in the file where the method can be used is changed to utf-8. the code containing bom will also contain a small X, and the verification code will be provided for other codes, the preliminary judgment is that there is content output in front of the tp execution to the output verification code, and the supervisor thought of clearing the previous output.

For example:

The code is as follows:

<? Php
Ob_start (); // it won't work if this parameter is not added (it seems that this parameter is not supported)
Echo "do not display ";
Ob_end_clean ();
Echo "as long as this is displayed ";
?>


Solution: modify the verification code generation method:

The code is as follows:

// Generate the verification code
Public function verifyimg (){
Import ("ORG. Util. Image ");
Ob_end_clean ();
Image: buildImageVerify ();
}

I hope this article will help you design PHP programs based on the ThinkPHP framework.

Examples in this article describes how to perfectly solve thinkphp verification code errors that cannot be displayed. I will share it with you for your reference...

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.