Welcome Guest, Not a member yet? Register   Sign In
How to get class reference
#1

[eluser]mezoni[/eluser]
I want have a reference a class in class constructor.
By example.

Code:
class Test extends Controller
{
    function Test()
    {
        parent::Controller();

        virtual_export('page_get_title', &$this, '_page_get_title');
    }

    function _page_get_title()
    {
        return $this->title;
    }
}

class Hooker  // library
{
    function hook_post_controller()
    {
        virtual_call('page_render');
        // ..
    }
}

class Page  // library
{

    function Page()
    {
        virtual_export('page_render', &$this, 'page_render');
    }

    function page_render()
    {
        $title = virtual_call('page_get_title');
        // ...
    }
}

But CI create object like this.

Code:
$CI = new $class();
$CI->$classvar = new $name;

If I use reference in class constructor I have copy of object but not reference.

if this were so...

Code:
$CI =& new $class();
$CI->$classvar =& new $name;

...then this will be possible.

But I don't know how to get class reference from class constructor.

I there any way to do this?


Messages In This Thread
How to get class reference - by El Forum - 07-15-2007, 03:12 AM
How to get class reference - by El Forum - 07-15-2007, 03:50 AM



Theme © iAndrew 2016 - Forum software by © MyBB