视图助手中的Zend重定向 - php

嗨,我有以下脚本可在视图帮助器中重定向

<?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 Helper类中时,不能使用$this->_helper->redirector->gotoUrl($url);,这是一个Action Controller函数。

您必须在View Helper中调用重定向器。

试试这个 :

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

PHP getallheaders替代 - php

我正在尝试从服务器上的apache切换到nginx。唯一的问题是我在PHP脚本中使用的getallheaders()函数,该函数不适用于Nginx。我已经尝试过用户在getallheaders函数上的php站点上提供的注释,但这并不返回所有请求标头。请告诉我如何解决这个问题。我真的想切换到Nginx。 参考方案 您仍然可以使用它,但是您必须像这里一样重新定义…

PHP:将字符串拆分为字母和数字部分的最佳方法 - php

我有几个格式的字符串AA11 AAAAAA1111111 AA1111111 分离字符串的字母和数字部分的最佳方法(最有效)? 参考方案 如果它们都是一系列字母,然后是一系列数字,并且没有非字母数字字符,那么sscanf()可能比regexp更有效$example = 'AAA11111'; list($alpha,$numeric) =…

php-casperjs获取内部文本 - php

我正在为casperjs使用php包装器-https://github.com/alwex/php-casperjs我正在网上自动化一些重复的工作,我需要访问一个项目的innerText,但是我尚不清楚如何从casperjs浏览器访问dom。我认为在js中我会var arr = document.querySelector('label.input…

PHP:检查目录是否为空的最佳和最简便的方法是什么 - php

Improve this question 我有一个包含数百个动态生成文件夹的根目录。随着时间的流逝,在这些目录必须为空的情况下,需要从系统中删除其中一些文件夹。实现这一目标的最佳的最短,最简单和/或最有效的方法是什么? 参考方案 使用glob:if (count(glob("path/*")) === 0 ) { // empty gl…

PHP:从函数返回值并直接回显它? - php

这可能是一个愚蠢的问题,但是……的PHPfunction get_info() { $something = "test"; return $something; } html<div class="test"><?php echo get_info(); ?></div> 有没有办…