天天看點

php請求轉發,Yaf 請求轉發 請求重定向

請求轉發:

public boolean Yaf_Controller_Abstract::forward( string  $module ,

string  $controller ,

string  $action ,

array  $params= NULL );

相關資料: http://yaf.laruence.com/manual/yaf.class.controller.forward.html

示例:

class IndexController extends Yaf_Controller_Abstract {

public funciton init() {

if($user_not_login) {

$this->forward("login");

}

}

}

?>

請求重定向:

public boolean Yaf_Controller_Abstract::redirect( string  $url );

相關資料:http://yaf.laruence.com/manual/yaf.class.controller.redirect.html

示例:

class IndexController extends Yaf_Controller_Abstract {

public funciton init() {

if($user_not_login)

$this->redirect("/login/");

}

}

?>

通過響應重定向

publicbooleanYaf_Response_Abstract::setRedirect( string $url );

相關資料:http://yaf.laruence.com/manual/yaf.class.response.setRedirect.html

通過header重定向

header("Location:http://www.baidu.com");

exit;