(Yaf >=1.0.0)
Yaf_Route_Regex::__construct — The __construct purpose
$match
, array $route
[, array $map
[, array $verify
]] )
match
一锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷式锟斤拷锟斤拷锟斤拷匹锟斤拷一锟斤拷锟斤拷锟斤拷锟絬ri锟斤拷锟斤拷锟斤拷锟斤拷锟狡ワ拷洌�Yaf_Route_Regex 锟斤拷锟斤拷锟斤拷FALSE锟斤拷
route
锟斤拷路锟斤拷锟斤拷锟斤拷匹锟斤拷晒锟斤拷锟斤拷锟絬ri时锟斤拷Yaf_Route_Regex锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷一锟斤拷m/c/a锟斤拷路锟缴★拷
锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟絤/c/a锟斤拷锟斤拷锟斤拷锟脚的o拷锟斤拷锟斤拷锟矫伙拷锟斤拷峁┮伙拷锟斤拷锟饺凤拷锟街碉拷锟斤拷锟斤拷锟斤拷锟斤拷锟侥拷戏锟绞斤拷锟铰凤拷伞锟� 锟斤拷锟斤拷, 锟斤拷也锟斤拷锟斤拷使锟斤拷map锟侥斤拷锟斤拷锟轿猰/c/a锟侥斤拷锟�.
map
锟斤拷匹锟戒到锟侥斤拷锟斤拷锟阶斤拷诺锟揭伙拷锟斤拷丫锟斤拷锟斤拷锟斤拷玫锟斤拷锟斤拷锟斤拷小锟�
verify
Example #1 Yaf_Route_Regex()example
<?php
/**
* Add a regex route to Yaf_Router route stack
*/
Yaf_Dispatcher::getInstance()->getRouter()->addRoute("name",
new Yaf_Route_Regex(
"#^/product/([^/]+)/([^/])+#", //match request uri leading "/product"
array(
'controller' => "product", //route to product controller,
),
array(
1 => "name", // now you can call $request->getParam("name")
2 => "id", // to get the first captrue in the match pattern.
)
)
);
?>
Example #2 Yaf_Route_Regex(as of 2.3.0)()example
<?php
/**
* 使锟矫讹拷态锟斤拷controller
*/
Yaf_Dispatcher::getInstance()->getRouter()->addRoute("name",
new Yaf_Route_Regex(
"#^/product/([^/]+)/([^/])+#", //match request uri leading "/product"
array(
'controller' => ":name", //使锟斤拷锟斤拷锟斤拷匹锟斤拷锟�:name, 也锟斤拷锟斤拷$1锟斤拷为controller
),
array(
1 => "name", // now you can call $request->getParam("name")
2 => "id", // to get the first captrue in the match pattern.
)
)
);
?>
Example #3 Yaf_Route_Regex()example
<?php
/**
* Add a regex route to Yaf_Router route stack by calling addconfig
*/
$config = array(
"name" => array(
"type" => "regex", //Yaf_Route_Regex route
"match" => "#(.*)#", //match arbitrary request uri
"route" => array(
'controller' => "product", //route to product controller,
'action' => "dummy", //route to dummy action
),
"map" => array(
1 => "uri", // now you can call $request->getParam("uri")
),
),
);
Yaf_Dispatcher::getInstance()->getRouter()->addConfig(
new Yaf_Config_Simple($config));
?>