Router API

class Router

外部管理代即将离任的url,传入请求uri的解析为参数设置,CakePHP可以派遣。

static Router::connect($route, $defaults = array(), $options = array())
Parameters:	
$route (string) – A string describing the template of the route
$defaults (array) – An array describing the default route parameters. These parameters will be used by default and can supply routing parameters that are not dynamic.
$options (array) – An array matching the named elements in the route to regular expressions which that element should match. Also contains additional parameters such as which routed parameters should be shifted into the passed arguments, supplying patterns for routing parameters and supplying the name of a custom routing class.

路线是连接请求url对象的方式在您的应用程序。在他们的核心路线是一组或正则表达式用于匹配请求的目的地。
例子:
Router::connect('/:controller/:action/*');

第一个参数将被用作一个控制器名称,而第二个是用作动作名称。“/ *”的语法使得这个贪婪的在比赛,它将请求路由/文章/索引以及请求像/文章/编辑/ 1 / foo / bar。

Router::connect(
    '/home-page',
    array('controller' => 'pages', 'action' => 'display', 'home')
);

上面显示了使用线路参数的默认值。并提供路由参数静态路由。
Router::connect(
    '/:lang/:controller/:action/:id',
    array(),
    array('id' => '[0-9]+', 'lang' => '[a-z]{3}')
);


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值