php8.5
Home/ Manual/ yaf / yaf_action_abstract/ Yaf_Action_Abstract::execute

Yaf_Action_Abstract::execute

PHP function Edit on GitHub ✎

(Yaf >=1.0.0)

Action entry point

Description

Yaf_Action_Abstract::execute(mixed ...$args): mixed

user should always define this method for an action, this is the entry point of an action. Yaf_Action_Abstract::execute may have arguments.

Note

The value retrieved from the request is not safe. you should do some filtering work before you use it.

Parameters

args

Return Values

The return value of the action method is not used by Yaf; output is written directly or collected by the view engine.

Examples

Yaf_Action_Abstract::execute()example

php
<?php
/** 
 * A controller example
 */
class ProductController extends Yaf_Controller_Abstract {
      protected $actions = array(
          "index" => "actions/Index.php",
      );
}
?>

Yaf_Action_Abstract::execute()example

php
<?php
/** 
 * ListAction
 */
class ListAction extends Yaf_Action_Abstract {
     public function execute ($name, $id) {
         assert($name == $this->getRequest()->getParam("name"));
         assert($id   == $this->getRequest()->getParam("id"));
     }
}
?>

The above example will output something similar to:

output
/**
 * Now assuming we are using the Yaf_Route_Static route 
 * for request: http://yourdomain/product/list/name/yaf/id/22
 * will result:
 */
 bool(true)
 bool(true)

See Also

  • Yaf_Request_Abstract::getParam
  • Yaf_Controller_Abstract::forward

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