php8.5
Home/ Manual/ yaf / yaf_request_simple/ Yaf_Request_Simple::__construct

Yaf_Request_Simple::__construct

PHP function Edit on GitHub ✎

(Yaf >=1.0.0)

Constructor of Yaf_Request_Simple

Description

Yaf_Request_Simple::__construct([string $method], [string $module], [string $controller], [string $action], [array $params])

Func

Parameters Parameters

Return Values

Examples

Yaf_Request_Simple::__construct example

php
<?php
/**
 * In a CLI script, build a request that skips the routing
 * process by giving the MVC names directly.
 */
$request = new Yaf_Request_Simple(
    "CLI",            // method
    "Index",          // module
    "Product",        // controller
    "detail",         // action
    array("id" => 10) // request parameters
);

var_dump($request->isRouted()); /* requests with MVC names are pre-routed */
var_dump($request->getModuleName());
var_dump($request->getControllerName());
var_dump($request->getActionName());
var_dump($request->getParam("id"));
?>

The above example will output something similar to:

output
bool(true)
string(5) "Index"
string(7) "Product"
string(6) "detail"
int(10)

See Also

  • Yaf_Request_Http
  • Yaf_Request_Abstract::isRouted
  • Yaf_Request_Abstract::getParam

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