Provides various official and user-released code examples and code reference. You are welcome to exchange and learn.
Sometimes, there is no problem where we need to display the verification code in the Local test environment. Once it is arranged on the server, where the verification code needs to be displayed cannot be displayed? If you encounter the same problem, please read it down.
Most of the problems are caused by the BOM header information. Generally, the BOM header information must be removed from the thinkphp configuration file. What is the BOM header information? Baidu will know about it.
My usual solution is to create a code file to remove the BOM header information of all files after setting it on the server, and then run it.
For example, I create a new delBom. php file in the root directory of the server. Run http://www.xxx.com/delbom.php. The Code is as follows:
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. _ http://www.k686.com ");
} 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 );
}
?>
AD: truly free, domain name + VM + enterprise mailbox = 0 RMB