Home>Article>Backend Development> What should I do if the verification code is not displayed when the PHP version is low?

What should I do if the verification code is not displayed when the PHP version is low?

藏色散人
藏色散人 Original
2021-09-03 09:14:39 2187browse

Solutions to the low version of php that does not display the verification code: 1. Install the dependencies required for php5-gd; 2. Create a clean.php file in the project root directory; 3. Clear the BOM.

What should I do if the verification code is not displayed when the PHP version is low?

The operating environment of this article: windows7 system, PHP5 version, DELL G3 computer

Low version of php does not display the verification code what to do?

The PHP5 verification code cannot be displayed, and the solution to the problem that the GD library cannot be displayed even if it is installed normally

I am working in JAVA, and I also maintain a direct takeover I am working on a PHP project with zero basic knowledge of PHP. I migrated the server of the project, added https to the domain name, and finally checked that it can be accessed normally, but the detailed functions have not been fully tested.

Suddenly one day there was a complaint that the verification code of the registration module could not be displayed normally (after temporarily removing it, I entered the background management module and found that the image upload function was not working properly. It is probably a problem). So I started searching for a solution online for 4 days intermittently.

In fact, the solution to the general situation is easy to find. Some keywords are php-gd, php-fpm (I configure nginx), php.ini, and cache clearing. But the debian system has unimaginable dependencies, and the dependency names of each version are different. The current system itself is a production environment server, and there are various versions of dependencies. In short, it is a big headache.

In the end, after trying countless dependency sources and updating the dependencies, I successfully installed the dependencies required for php5-gd. Finally, phpinfo also displayed GD version information and supported image formats. However, the verification code still could not be displayed. . . . . .

After trying countless search keywords, "php5 does not display the verification code even after installing gd" I finally found a post that mentioned the BOM header. This became clear because I was using crt to remotely log in to the server. This BOM header will also appear when editing some files, so create a clean.php file in the project root directory,

Paste the following code

"; }else{ $dirname = $basedir."/".$file; checkdir($dirname); } } }//end while closedir($dh); }//end if($dh }//end function function checkBOM($filename){ global $auto; $contents = file_get_contents($filename); $charset[1] = substr($contents, 0, 1); $charset[2] = substr($contents, 1, 1); $charset[3] = substr($contents, 2, 1); if(ord($charset[1]) == 239 && ord($charset[2]) == 187 && ord($charset[3]) == 191){ if($auto == 1){ $rest = substr($contents, 3); rewrite ($filename, $rest); return "BOM found, automatically removed."; }else{ return ("BOM found."); } } else return ("BOM Not Found."); }//end function function rewrite($filename, $data){ $filenum = fopen($filename, "w"); flock($filenum, LOCK_EX); fwrite($filenum, $data); fclose($filenum); } ?>

Directly access https:/ with a browser /url/clean.php

If there is a problem, you will see many such logs, and then revisit the verification code page

Normal access~

The problem of uploading pictures is actually caused by the domain name being changed to https but the upload module configuration not being changed. Adding https is normal too

Recommended study: "PHP video tutorial

The above is the detailed content of What should I do if the verification code is not displayed when the PHP version is low?. 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