PHP - Manual: Yaf_Route_Static::assemble
2024-12-22
(Yaf >=2.3.0)
Yaf_Route_Static::assemble — 组合url
$info
, array $query
= ?): string根据指定参数和自定义参数将static这个route组合成一个url
info
需要传入一个数组,数组中每个key可为:m、:c、:a,:m代表module,:c代表controller, :a代表action
query
用户自定义的query string,将根据此路由规则拼接在url中
示例 #1 Yaf_Route_Static::assemble()example
<?php
$router = new Yaf_Router();
$route = new Yaf_Route_Static();
$router->addRoute("static", $route);
var_dump($router->getRoute('static')->assemble(
array(
':a' => 'yafaction',
'tkey' => 'tval',
':c' => 'yafcontroller',
':m' => 'yafmodule'
),
)
);
var_dump($router->getRoute('static')->assemble(
array(
':a' => 'yafaction',
'tkey' => 'tval',
':c' => 'yafcontroller',
':m' => 'yafmodule'
),
array(
'tkey1' => 'tval1',
'tkey2' => 'tval2'
)
)
);
以上例程的输出类似于:
string(%d) "/yafmodule/yafcontroller/yafaction" string(%d) "/yafmodule/yafcontroller/yafaction?tkey1=tval1&tkey2=tval2"
官方地址:https://www.php.net/manual/en/yaf-route-static.assemble.php