aliyun centos php 8.0.8 nginx 1.21.0 thinkphp6最新版本 5.7.34 - MySQL
底层抛出错误:
"str_replace(): Argument #2 ($replace) must be of type array|string, int given"
底层源码: /**
* 获取页码对应的链接
*
* @access protected
* @param int $page
* @return string
*/
protected function url(int $page): string
{
if ($page <= 0) {
$page = 1;
}
if (strpos($this->options['path'], '[PAGE]') === false) {
$parameters = [$this->options['var_page'] => $page];
$path = $this->options['path'];
} else {
$parameters = [];
$path = str_replace('[PAGE]', $page, $this->options['path']);
}
if (count($this->options['query']) > 0) {
$parameters = array_merge($this->options['query'], $parameters);
}
$url = $path;
if (!empty($parameters)) {
$url .= '?' . http_build_query($parameters, '', '&');
}
return $url . $this->buildFragment();
}
str_replace 第二个参数给的是字符串或者数组,然而是整形。原码:
public function list(int $pageNum,int $list_rows=5):array
{
$res = $this->where('status', config('status.mysql.table_normal'))->paginate([
'list_rows' => $list_rows,
'type' => 'Bootstrap',
'var_page' => 'page',
'page' => $pageNum,
'path' => 'javascript:list([PAGE])'
]);
return [
'list' => $res->toArray(),
'render' => $res->render(),
'page' => $pageNum
];
}
请问这个是兼容问题,还是我的版本太高? 最佳答案
