php教程

Yaf_Route_Simple::assemble

(Yaf >=2.3.0)

Yaf_Route_Simple::assemble组合url

说明

public Yaf_Route_Simple::assemble ( array $info [, array $query ] ) : string

根据指定参数和自定义参数将simple这个route组合成一个url

参数

info

需要传入一个数组,数组中每个key可为:m、:c、:a,:m代表module,:c代表controller, :a代表action

query

用户自定义的query string,将根据此路由规则拼接在url中

范例

Example #1 Yaf_Route_Simple::assemble()example

<?php

$router 
= new Yaf_Router();

$route  = new Yaf_Route_Simple('m''c''a');

$router->addRoute("simple"$route);

var_dump($router->getRoute('simple')->assemble(
            array(
                
':a' => 'yafaction',
                
'tkey' => 'tval',
                
':c' => 'yafcontroller',
                
':m' => 'yafmodule'
                
),
            array(
                
'tkey1' => 'tval1',
                
'tkey2' => 'tval2'
                
)
            ));

以上例程的输出类似于:

string(64) "?m=yafmodule&c=yafcontroller&a=yafaction&tkey1=tval1&tkey2=tval2"

返回值

User Contributed Notes

There are no user contributed notes for this page.

CopyRight © 2008-2022 verySource.Com All Rights reserved. 京ICP备17048824号-1 京公网安备:11010502034788