Home > Backend Development > PHP Tutorial > The perfect way to solve the problem of thinkphp verification code error and unable to be displayed, thinkphp verification code_PHP tutorial

The perfect way to solve the problem of thinkphp verification code error and unable to be displayed, thinkphp verification code_PHP tutorial

WBOY
Release: 2016-07-13 10:12:08
Original
810 people have browsed it

The perfect solution to thinkphp verification code error that cannot be displayed, thinkphp verification code

The example in this article describes the perfect solution to the problem that thinkphp verification code cannot be displayed due to errors. Share it with everyone for your reference. The specific analysis is as follows:

I finished the verification code part today, and I was very happy when I thought that TP comes with a verification picture, but I couldn’t come up with it after tinkering for a long time, and I always looked like a little X.

Official tips are as follows:
If the verification code cannot be displayed, please check:
① Whether PHP has installed GD library support;
② Is there any output before output (especially the BOM header information output of UTF8);
③ Whether the Image class library is imported correctly;
④ If it is a Chinese verification code, check whether the font file has been copied to the directory where the class library is located;

But after half a day of testing, it didn’t work! I found a usable method on the Internet and put it in a file to execute. Enter tp through the index.php entry and enter the small A small

Similar to:


Copy code The code is as follows:
ob_start();//It won’t work without adding this (it seems it can be done without adding this)
echo "Don't show";
ob_end_clean();
echo "Just show this";
?>

Solution, modify the method of generating verification code:
Copy code The code is as follows:
//Generate verification code
public function verifyimg(){
import("ORG.Util.Image");
ob_end_clean();
Image::buildImageVerify();
}
I hope this article will be helpful to everyone’s PHP programming based on the ThinkPHP framework.

http://www.bkjia.com/PHPjc/924542.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/924542.htmlTechArticleThe perfect solution to the thinkphp verification code error that cannot be displayed. The example of thinkphp verification code in this article tells the perfect solution to the thinkphp verification code error. The method cannot be displayed. Share it with everyone for your reference...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template