gpt4 book ai didi

php - Zend 在 View 助手中重定向

转载 作者:行者123 更新时间:2023-12-03 23:03:49 25 4
gpt4 key购买 nike

您好,我有以下脚本可以在 View 助手中重定向

<?php
class Application_View_Helper_ExistUserRev extends Zend_View_Helper_Abstract{

public function existUserRev($params,$user)
{
$businessReviewMapper = new Application_Model_Mapper_BusinessReviewsMapper();
$businessReviewModel = new Application_Model_BusinessReviews();
$result = $businessReviewMapper->userReviewStatus($user>getUserId(),$params['bzid']);
if($result){
$url = 'http://www.akrabat.com';
$this->_helper->redirector->gotoUrl($url);
}
}
}
?>

但我上面的重定向似乎不起作用。我如何在我的 zend 应用程序的 View 助手中重定向?谢谢

最佳答案

因为你在一个 View Helper 类中,你不能使用 $this->_helper->redirector->gotoUrl($url);,这是一个 Action Controller 函数。

您必须在 View 助手中调用重定向器。
试试这个:

$_redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
$_redirector->gotoUrl($url);

关于php - Zend 在 View 助手中重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15967644/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com