ThinkPHP opens the verification code page to display the solution for garbled text, thinkphp verification code. ThinkPHP opens the verification code page to display the solution to garbled code. thinkphp verification code this article describes how ThinkPHP opens the verification code page to display garbled code. We will share with you the ThinkPHP verification code. the thinkphp verification code is displayed on the verification code page.
This example describes how ThinkPHP solves the problem of garbled characters on the verification code page. Share it with you for your reference. The specific analysis is as follows:
When developing with thinkphp, the verification code may be garbled. the solution is to put the following file in the root directory, which can be solved after access. the specific PHP code is as follows:
The code is as follows:
<? Php
If (isset ($ _ GET ['dir']) {// sets the file directory
$ Basedir = $ _ GET ['dir'];
} Else {
$ Basedir = '.';
}
$ Auto = 1;
Checkdir ($ basedir );
Function checkdir ($ basedir ){
If ($ dh = opendir ($ basedir )){
While ($ file = readdir ($ dh ))! = False ){
If ($ file! = '.' & $ File! = '..'){
If (! Is_dir ($ basedir. "/". $ file )){
Echo "filename: $ basedir/$ file". checkBOM ("$ basedir/$ file ")."
";
} Else {
$ Dirname = $ basedir. "/". $ file;
Checkdir ($ dirname );
}
}
}
Closedir ($ dh );
}
}
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 .");
}
Function rewrite ($ filename, $ data ){
$ Filenum = fopen ($ filename, "w ");
Flock ($ filenum, LOCK_EX );
Fwrite ($ filenum, $ data );
Fclose ($ filenum );
}
?>
I hope this article will help you design PHP programs based on the ThinkPHP framework.
In this example, ThinkPHP opens the verification code page and displays garbled code. I will share it with you for your reference...