php8.5
Home/ Manual/ yaf / yaf_route_static/ Yaf_Route_Static::assemble

Yaf_Route_Static::assemble

PHP function Edit on GitHub ✎

(Yaf >=2.3.0)

Assemble a url

Description

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

Assemble a url.

Parameters

info
query

Return Values

Returns a String.

Errors/Exceptions

Throws Yaf_Exception_TypeError if info keys ':c' and ':a' are not set.

Examples

Yaf_Route_Static::assemble()example

php
<?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'
            )
        )
);

The above example will output something similar to:

output
string(%d) "/yafmodule/yafcontroller/yafaction"
string(%d) "/yafmodule/yafcontroller/yafaction?tkey1=tval1&tkey2=tval2"

Source: reference/yaf/yaf_route_static/assemble.xml · from the official PHP manual (php/doc-en)