Zend framework重定向的方法

        zend framework重定向的方法有三种。render, forward, redirect。它们各自的用法是什么样子的呢?有什么区别呢?

        一.render

       render是用来调视图用的,不会调用ACTION内部代码

    $this->render('upload') ;

       这句话的意思是{当前Module}/{当前Controller}/upload.phtml

       二.forward

 

      forward的写法比较灵活。

   $this->_forward('upload') ;

      这句话的意思是{当前Module}/{当前Controller}/upload

 

 

   $this->_forward('upload', 'index') ;

      这句话的意思是{当前Module}/index/upload

 

 

   $this->_forward('upload', 'index', 'admin') ;

      这句话的意思是admin/index/upload

 

      forward还可以传参,如下所示。

   $params = array(
     'a' => '1',
     'b' => '2'
   ) ;
   $this->_forward('upload', 'index', 'admin', $params) ;

      这句话的意思是admin/index/upload/a/1/b/2

 


       三.redirect

      redirect写法比较简单,方法中填写跳转路径就行了,要从module开始写。    

   $this->_redirect('/admin') ;

      这句话的意思是/admin

   $this->_redirect('/admin/index') ;

      这句话的意思是/admin/index

 

 

   $this->_redirect('/admin/index/upload') ;

      这句话的意思是/admin/index/upload

 

      如果redirect想要传参怎么办呢?那就只能也写在链接里了。如下    

   $this->_redirect('/admin/index/upload/a/1/b/2') ;

      这句话的意思是/admin/index/upload/a/1/b/2

 

 

转载于:https://www.cnblogs.com/james1207/p/3278128.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值