


The solution to the problem that the php verification code image cannot be displayed: first open the corresponding PHP file; then add the code as "ob_clean();" before the header output; finally save the modification.
The operating environment of this article: Windows 7 system, PHP version 7.1, DELL G3 computer
PHP verification code image cannot be displayed
I thought the gd2 library was not opened, but I checked with phpinfo and found that it was opened.
Solution
Add before the header output :
ob_clean(); //关键代码,防止出现'图像因其本身有错无法显示'的问题。 header("Content-type:image/jpeg");
Example:
private function outPut() { ob_clean(); //关键代码,防止出现'图像因其本身有错无法显示'的问题。 header('Content-type:image/png'); imagepng($this->img); imagedestroy($this->img); }
[Recommended learning: PHP video tutorial]
The above is the detailed content of What should I do if the php verification code image cannot be displayed?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function
