簡體   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