Suppose that I've this class:
class Loader
{
function library($name)
{
require $name . '.php';
}
}
and now I include the class foo
($name) inside my controller, like this:
class Controller
{
function __construct()
{
$this->load = new Loader();
}
}
class Child_Controller extends Controller
{
function __construct()
{
parent::__construct();
$this->load->library('foo');
init();
}
}
is possible, for example, access to the included class inside $this
? Like:
class Child_Controller extends Controller
{
//..construct above..
function init()
{
$this->print('some text');
}
}
where print
is a method of foo
, the class included:
class Foo
{
function print($message)
{
echo "your message: " . $message;
}
}
So, summing, I want include in the child controller, in $this
, all the method of the included class by the Loader class extended by the base controller. Is this possible?
Or another idea would be create dynamically in the Child_Controller, a property that take the name of the included class, so, for call the method of foo
I can do something like:
$this->Foo->print('some text');