search
HomeBackend DevelopmentPHP ProblemWhat should I do if the php verification code image cannot be displayed?

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.

What should I do if the php verification code image cannot be displayed?

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!

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function