Home>Article>PHP Framework> How to solve the problem of garbled characters in thinkphp pagination
The problem of garbled characters is due to problems in constructing URLs in the thinkphp paging class. Thinkphp's paging URLs use "/" to separate parameters. When passing data to In the URL, after the URL is encrypted, it will be garbled when passed for the second time. If we use "?" and "&" to separate the parameters, this problem will not occur.
So the content to be modified is thinkphp’s paging class file: /ThinkPHP/Extend/Library/ORG/Util/Page.class.php file.
The specific modified code is:
1. Add a custom function at the end of the thinkphp paging class file Page.class.php to replace the parameter separator in the URL. The function content is as follows:
private function clin_page_url($parameter){ $url = U(''); $url = str_replace('.html', '?', $url); foreach ($parameter as $key => $value) { $url .= $key.'='.$value.'&'; } $url = substr($url, 0,-1); return $url; }
Self-study PHP blog
2. Modify the final generated url
In line 99 of the Page.class.php file, replace the original
$url=U('',$parameter);
is modified to:
$url=$this->clin_page_url($parameter); // 生成标准的url
After these two steps of modification, the problem of thinkphp paging garbled characters can be solved.
Related references:thinkphp tutorial
The above is the detailed content of How to solve the problem of garbled characters in thinkphp pagination. For more information, please follow other related articles on the PHP Chinese website!