AI摘要

本文介绍了如何在phpGrace框架中自定义路由设置。首先,在入口页开启路由配置并定义PG_ROUTE。然后,在分组目录内找到router.php文件编写路由规则。路由规则包括访问路径、控制器、方法和参数。例如,'about' => array('index', 'about', array(120, 'grace'))表示访问/about会调用index控制器的about方法,并传递参数120和grace。
本文介绍了如何

在入口页开启路由配置

<?php
define('PG_ROUTE', true);//在框架核心文件引用前定义
include 'phpGrace/phpGrace.php';

在分组目录内找到 router.php 编写路由规则

如:

return array(
    'about' => array('index', 'about', array(120, 'grace')),
    'other' => array('index', 'other')
);

路由: 'about' => array('index', 'about', array(120, 'grace'))
代表:/about 会访问 index 控制器内的 about 方法 并携带 参数 120和 grace (保存在 $this->gets) 。
路由: 'other' => array('index', 'other')
代表:/other 会访问 index 控制器内的 other 方法。



最后修改:2019 年 12 月 23 日
点赞的人是最酷的