Home  >  Article  >  Backend Development  >  php cannot display verification code

php cannot display verification code

藏色散人
藏色散人Original
2019-09-29 10:09:531889browse

php cannot display verification code

#php cannot display the verification code?

The verification code image cannot be displayed. There are generally three reasons (these reasons are basically the same on the Internet):

(1) PHP does not have the gd2 module installed, you can use phpinfo() function view.

(2) The code is most likely edited using a text editor like editpuls or notepad, then their default encoding format is utf-8 with BOM.

UTF-8 BOM is also called UTF-8 signature. In fact, the BOM of UTF-8 has no effect on UFT-8. It is added to support UTF-16 and UTF-32. The meaning of BOM signature is It just tells the editor what encoding the current file uses to facilitate the editor's identification. However, although the BOM is not displayed in the editor, it will produce output, just like an extra blank line. Generally I use UTF-8 BOM-free format, so you need to change the encoding format of the code to BOM-free format.

(3) Use ob_clean() to clear the cache. There cannot be output before header().

The function ob_clean is used to discard the contents of the output buffer.

If you have many generated image files, you need to clear the buffer frequently if you want to access them correctly.

If the above three reasons have been checked and the verification code still cannot be displayed, another reason may be that the gd2 module is not actually installed successfully, and what is displayed in phpinfo() is an illusion. In this case, Reloading this module will not overwrite the broken one. You need to rebuild the environment and give it a try.

For more PHP related knowledge, please visit PHP Tutorial!

The above is the detailed content of php cannot display verification code. 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