Yaf_Response_Abstract::setRedirect
PHP function
Edit on GitHub ✎
(Yaf >=1.0.0)
Redirect to another URL
Description
Yaf_Response_Abstract::setRedirect(string $url): bool|null
Redirect the client to another URL (sends a Location header).
Parameters
urlThe URL to redirect to.
Return Values
Returns true on success, or null on failure.
Examples
Yaf_Response_Abstract::setRedirect example
php
<?php
class AccountController extends Yaf_Controller_Abstract
{
public function indexAction()
{
if (!Yaf_Session::getInstance()->has("login")) {
/* send a Location header pointing to the login page */
$this->getResponse()->setRedirect("/account/login");
return false; // nothing to render here
}
}
}
?>See Also
Yaf_Controller_Abstract::redirect