I have a problem with objects in PHP.
<?php
error_reporting( E_ALL | E_STRICT );
##
class Loader {
function view() {
echo 'I did it! )';
}
}
class Controller {
public $loader;
function __construct() {
$this -> loader = new Loader;
}
}
##
class Foo extends Controller {
function index() {
$this -> loader -> view();
}
}
There are three classes: Loader, Controller and Foo. I want to use method of class Loader in Foo class. I know that __construct() wouldn't run because Foo extends from Controller, but anyway I don't get any error.
So how to use that method there with condition that in Foo I won't need to write more code?
P.S. I'm creating MVC...