Home >PHP Framework >ThinkPHP >What should I do if the thinkphp verification code does not display?
The example in this article describes the perfect method to solve the problem of thinkphp verification code being unable to be displayed. Share it with everyone for your reference. The specific analysis is as follows:
The official tip is as follows:
If the verification code cannot be displayed, please check:
① Whether PHP has installed GD library support;
② Whether there is any before output The 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 is copied to the directory where the class library is located.
Related recommendations: "ThinkPHP Tutorial"
But testing for half a day doesn’t work! I found a useful method on the Internet and put it into a file to execute. Enter tp through the index.php entry and enter the small A small x will appear, and verification codes will appear for other codes. The initial judgment is that there is content output before the verification code is output when tp is executed. I just thought of clearing the previous output.
Similar:
The code is as follows:
<?php ob_start();//不加这个是不行的(貌似不加可以) echo "不要显示"; ob_end_clean(); echo "只要显示这"; ?>
Solution, modify the method of generating verification code:
The code is as follows:
//生成验证码 public function verifyimg(){ import("ORG.Util.Image"); ob_end_clean(); Image::buildImageVerify(); }
The above is the detailed content of What should I do if the thinkphp verification code does not display?. For more information, please follow other related articles on the PHP Chinese website!