tags:

views:

31

answers:

1

Hi,

Attempting to dive in to Kohana and I'm reading the Unofficial 3.0 Kohana wiki as it's more user friendly than the user docs atm imo.

It mentions "Binding Data to a View", like so:

<?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

Which outputs:

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

How is this possible? Or what's this method/process called? The variables are set after they are "used", if you like, hence my confusion.

Thanks for any insight.

+3  A: 

It's called passing by reference. See more at http://www.php.net/manual/en/language.references.pass.php.

Wrikken
thanks for the link, will look in to it. Does this bear any relevance to the term "late binding"?
Ross
Wrikken
thanks again for clarification.
Ross