yaf框架的一些函数

原文地址:http://php8848.com/3447.html

controller层的知识
1.  $this->getView  取得与action同名的view
2.  在action中关闭模版输出
Yaf_Dispatcher::getInstance()->autoRender(FALSE); 或者 Yaf_Dispatcher :: getInstance() -> disableView();
3.  如果action过于复杂,可以通过  actions数组来定义一个继承actions基类的类去单独创建一个文件来完成逻辑, 实现方法,只要在actons属性中定义一个数组  array(‘action’=>’action/inex.php’);  这样就能调用,而把逻辑放在 execute里面。
4.  搞清楚view层的方法,  assign()和  assignRef()的关系  , 目前来看是相同的

5. forward 和render的关系
render是视图渲染函数,调用该函数可以返回选然后的字符串,而且,assign的值在同一次的请求中会共用。
$this->forward($action, array(“name” => $value)); 是一个跳转函数,但是并不会马上跳转,而是会等到action结束之后在跳转。第一个参数是一个action名称,第二个参数是传递的参数。

6.  forward到其他的controller的action应该怎么写

7. action如何区分是 post 还是get请求,还是 ajax请求
可以用
$this->getRequest()->isGet()
$this->getRequest()->isPost()
$this->getRequest()->isXmlHttpRequest()
来判定是get还是post还是ajax请求

8. forward 函数是一个有几种方式,最后一个参数必须是数组
public boolean Yaf_Controller_Abstract::forward( string  $action , array  $params = NULL );
public boolean Yaf_Controller_Abstract::forward( string  $controller , string  $action , array  $params = NULL );
public boolean Yaf_Controller_Abstract::forward( string  $module , string  $controller , string  $action , array  $params = NULL );

9. redirect 函数的用法
$this->redirect(“/login/”);   可以写全路径也可以写相对路径,区别在于在最前面是否有反斜杠。 也可以写http请求,就会直接夸张跳转。

转载于:https://my.oschina.net/u/2250930/blog/362553

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值