Provides various official and user-released code examples. For code reference, you are welcome to exchange and learn to search for Chinese characters. Passing parameters through get after pagination can cause Chinese garbled characters. The solution is found on the Internet, share.
// Solve the problem of paging Chinese garbled characters
$ Key = $ this-> _ param ('key ');
If (! Mb_check_encoding ($ key, 'utf-8 ')){
$ Key = iconv ('gbk', 'utf-8', $ key );
}
Create a file GetcodingBehavior. class. php In the path of ThinkPHP \ Lib \ Behavior.
The Code is as follows:
/**
* $ _ GET encoding solves url Chinese problems
* @ Author Administrator
*
*/
Class GetcodingBehavior extends Behavior {
Public function run (& $ params ){
Foreach ($ _ GET as $ k => $ v ){
If (! Is_array ($ v )){
If (! Mb_check_encoding ($ v, 'utf-8 ')){
$ _ GET [$ k] = iconv ('gbk', 'utf-8', $ v );
}
} Else {
Foreach ($ _ GET ['_ URL _'] as $ key => $ value ){
If (! Mb_check_encoding ($ value, 'utf-8 ')){
$ _ GET ['_ URL _'] [$ key] = iconv ('gbk', 'utf-8', $ value );
}
}
}
}
}
}
AD: truly free, domain name + VM + enterprise mailbox = 0 RMB