Yaf_Route_Regex::assemble
(Yaf >=2.3.0)
Yaf_Route_Regex::assemble — 组合url
说明
public Yaf_Route_Regex::assemble(array
$info
, array $query
= ?): string根据指定参数和自定义参数将regex这个route组合成一个url
在regex route使用assemble需要在初始化时指定reverse参数,否则将不能正常工作
参数
-
info
-
需要传入一个数组,数组的key可以为:a、:c、:m,:a表示action,:c表示controller,:m表示module。
-
query
-
用户自定义的query string,将根据此路由规则拼接在url中
范例
示例 #1 Yaf_Route_Regex::assemble()example
<?php
$router = new Yaf_Router();
$route = new Yaf_Route_Regex(
"#^/product/([^/]+)/([^/])+#",
array(
'controller' => "product", //route to product controller,
),
array(),
array(),
'/:m/:c/:a'
);
$router->addRoute("regex", $route);
var_dump($router->getRoute('regex')->assemble(
array(
':m' => 'module',
':c' => 'controller',
':a' => 'action'
),
array(
'tkey1' => 'tval1',
'tkey2' =>
'tval2'
)
)
);
以上例程的输出类似于:
string(49) "/module/controller/action?tkey1=tval1&tkey2=tval2"
返回值

User Contributed Notes
There are no user contributed notes for this page.
备份地址:http://www.lvesu.com/blog/php/yaf-route-regex.assemble.php