繁体   English   中英

php绑定数据解释(可能kohana具体?)

[英]php bind data explanation (possibly kohana specific?)

尝试潜入Kohana并且我正在阅读Unofficial 3.0 Kohana wiki,因为它比用户docs atm imo更加用户友好。

它提到“将数据绑定到视图”,如下所示:

<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Welcome extends Controller {

    public function action_index()
    {
        $about_page = View::factory('pages/about')
                            ->bind('title', $title)
                            ->bind('header', $header);

        $title='This is my title';
        $title='This is my header';
        $this->request->response = $about_page;
    }

} // End Welcome

哪个输出:

<html>
<head> 
<title>This is my title</title> 
</head> 
<body> 
<h1>This is my header</h1> 
</body> 
</html>

这怎么可能? 或者这个方法/过程叫什么? 变量是在“使用”之后设置的,如果你愿意,那么我的困惑。

感谢您的任何见解。

它被称为通过引用传递。 有关详情,请访问http://www.php.net/manual/en/language.references.pass.php

我在研究kohana框架时遇到过这种情况。

查看此链接,shadowhand将其置于非常基本的术语中: http//forum.kohanaframework.org/discussion/5038/views-difference-between-assign-bind-and-set/p1

这个答案不是为了帮助原始人,而是为了节省时间,如果他们被卡住了;)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM