Get the App
SLTechnology News&Howtos  ›  Development  › 

How to solve the problem that the picture of verification code generated by php can not be opened?

Shulou Source: shulou.com Published: 2022-06-03 10:40:05 11月15日 Update

This article introduces how to solve the problem that the picture of php CAPTCHA can not be opened. The content is very detailed. Interested friends can use it for reference. I hope it can help you.

Php generated CAPTCHA image can not open the solution: 1, block the output image code; 2, check the code errors; 3, check whether the gd library is open; 4, modify the font path when generating CAPTCHA; 5, add the "ob_clean ()" code.

This article operating environment: Windows7 system, PHP7.1, Dell G3 computer.

What if the picture of php generated CAPTCHA cannot be opened?

The problem that the CAPTCHA picture generated by php does not display

1. First block out the code to output the picture: header ("Content-Type:image/png")

two。 Visit the picture and check for code errors

3. Then check whether there is an output before the CAPTCHA. If there is an output, the CAPTCHA will not be displayed

4. Check whether the gd library is open

5. The CAPTCHA does not display or report an error; refresh the page, and the CAPTCHA is fleeting because the font path is incorrect (it must be an absolute path) when the CAPTCHA is generated, as shown in the figure:

6. If there is no problem, it can be solved perfectly by adding ob_clean () code before header ("Content-Type:image/png") (Note: the purpose of ob_clean () is to clear the ob cache)

On how to solve the php generation of CAPTCHA pictures can not open the problem to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Validate picture generate code check problem output content path font more error help good useful interest method reason boy buddy Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Docker Huawei MariaDB macOS