PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Utility Methods

Besides the accessors and view integration methods, Zend_Controller_Action has several utility methods for performing common tasks from within your action methods (or from pre- and post-dispatch).

  • _forward($action, $controller = null, $module = null, array $params = null): perform another action. If called in preDispatch(), the currently requested action will be skipped in favor of the new one. Otherwise, after the current action is processed, the action requested in _forward() will be executed.

  • _redirect($url, array $options = array()): redirect to another location. This method takes a URL and an optional set of options. By default, it performs an HTTP 302 redirect.

    The options may include one or more of the following:

    • exit: whether or not to exit immediately. If requested, it will cleanly close any open sessions and perform the redirect.

      You may set this option globally within the controller using the setRedirectExit() accessor.

    • prependBase: whether or not to prepend the base URL registered with the request object to the URL provided.

      You may set this option globally within the controller using the setRedirectPrependBase() accessor.

    • code: what HTTP code to utilize in the redirect. By default, an HTTP 302 is utilized; any code between 301 and 306 may be used.

      You may set this option globally within the controller using the setRedirectCode() accessor.

Zend Framework