php8.5
Home/ Manual/ yaf / yaf_controller_abstract/ Yaf_Controller_Abstract::getInvokeArg

Yaf_Controller_Abstract::getInvokeArg

PHP function Edit on GitHub ✎

(Yaf >=1.0.0)

Retrieve one action invocation argument

Description

Yaf_Controller_Abstract::getInvokeArg(string $name): string|null

Returns a single invocation argument of the current action, given its name. Invocation arguments are passed to the action through Yaf_Controller_Abstract::forward.

Parameters

name

The name of the invocation argument to retrieve.

Return Values

The argument value, or null if it does not exist.

Examples

Yaf_Controller_Abstract::getInvokeArg example

php
<?php
class UserController extends Yaf_Controller_Abstract
{
    public function indexAction() {
        // forward to the profile action of this controller,
        // carrying invocation arguments
        $this->forward("profile", array("name" => "laruence"));
        return false; // ends the current flow
    }

    public function profileAction() {
        // retrieve one invocation argument by name
        var_dump($this->getInvokeArg("name"));
        var_dump($this->getInvokeArg("missing"));
    }
}
?>

The above example will output something similar to:

output
string(8) "laruence"
NULL

See Also

  • Yaf_Controller_Abstract::getInvokeArgs
  • Yaf_Controller_Abstract::forward

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