Jump to content

Include a file into a class?


LemonInflux

Recommended Posts

<?php

class parent {
    var $child;

    function parent() {
        $this->child = new child;
    }
}

class child extends parent {
    var $var;
}

?>

 

Normally, I'd call parent->child->var to get the child var. However, I want to be able to include a file, in which I can use $this->var to call the var. I don't mean include a file containing the class, I mean include a separate file that can be treated as if it is in the child. Is there a way to do this?

 

I'm sorry if this is badly explained, but I can't think of a clear way to do this. I think the zend framework uses something like this, because you set things as $this->view->var and retrieve them in the view as $this->var. But I couldn't work out how they did it :(

 

Any help is appreciated.

 

Thanks in advance,

Tom

Link to comment
https://forums.phpfreaks.com/topic/115833-include-a-file-into-a-class/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.