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

藏色散人
Release: 2023-03-07 07:36:02
Original
2028 people have browsed it

The solution to the problem that the php verification code cannot be displayed: first open the corresponding code file; then add the code "ob_clean();" before the header output to solve the problem of the verification code not being displayed.

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

Recommended: "PHP Video Tutorial"

PHP verification code image cannot be displayed problem

I thought the gd2 library was not open, but I checked it with phpinfo and found that it was open

Solution

Add before the header output:

ob_clean (); //Key code to prevent the problem of 'the image cannot be displayed because of its own errors'.

header("Content-type:image/jpeg");

Example:

  private function outPut() {
        ob_clean();  //关键代码,防止出现'图像因其本身有错无法显示'的问题。
        header('Content-type:image/png');
        imagepng($this->img);
        imagedestroy($this->img);
    }
Copy after login

The above is the detailed content of What should I do if the php verification code cannot be displayed?. For more information, please follow other related articles on the PHP Chinese website!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!