/news-1.html或/news/1.html 这样的方式
Page类的简单修改如下:
增加个属性
public $route = ''; //路由设置把show方法的这两行代码修改/* 生成URL */
$this->parameter[$this->p] = '[PAGE]';
$this->url = U(ACTION_NAME, $this->parameter);修改为/* 生成URL */
if (!empty($this->route)) {
if (stripos($this->route, '[PAGE]') !== false)
unset($this->parameter[$this->p]);
$this->url = str_replace('[page]', '[PAGE]', U($this->route, $this->parameter));
} else {
$this->parameter[$this->p] = '[PAGE]';
$this->url = U(ACTION_NAME, $this->parameter);
}完成!实例
$page = new Page($count, 10);
//$page->route = '/news/[PAGE]'; //实现 news/1.html
$page->route = '/news-[PAGE]'; //实现 news-1.html 