php8.5
Home/ Manual/ yaf / yaf_route_supervar/ Yaf_Route_Supervar::__construct

Yaf_Route_Supervar::__construct

PHP function Edit on GitHub ✎

(Yaf >=1.0.0)

Construct a supervar route

Description

Yaf_Route_Supervar::__construct(string $supervar_name)

Construct a supervar route. A supervar route expects a query variable to carry a PATH_INFO style URI.

Parameters

supervar_name

The name of the query variable that carries the URI.

Return Values

No value is returned.

Examples

Yaf_Route_Supervar::__construct example

php
<?php
/**
 * Add a supervar route to the Yaf_Router route stack.
 *
 * The URI is expected in the query variable named below,
 * e.g. http://yourdomain.com/index.php?_url=/product/detail/id/10
 */
Yaf_Dispatcher::getInstance()->getRouter()->addRoute("supervar",
    new Yaf_Route_Supervar("_url")
);
?>

The above example will output something similar to:

output
/* http://yourdomain.com/index.php?_url=/product/detail/id/10
 * routes to the following values:
 */
array(
  "controller" => "product",
  "module"     => "index", //(default)
  "action"     => "detail", //(default)
)

/**
 * and request parameters:
 */
array(
  "id" => 10
)

See Also

  • Yaf_Route_Supervar::route
  • Yaf_Route_Supervar::assemble

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