Welcome Guest, Not a member yet? Register   Sign In
Extending Controllers and Inheritance
#1

[eluser]underskor[/eluser]
Can't figure this one out. Seems like it would work to me. No doubt I've overlooked something stupidly simple.

Code:
class Dinner extends Controller {
    var $meal = 'Pie';
    
    function __construct() {
        parent::Controller();
    }

    function index() {
        echo $this->meal; //Outputs 'Pie' as expected
    }

}

Code:
include('dinner.php');

class Dessert extends Dinner {

    function __construct() {
        parent::Dinner(); //(Line 9) Fatal error: Call to undefined method Dinner::dinner() in dessert.php on line 9
    }
    

    function index() {
        echo $this->meal = 'Cake';
    }

}

Trying to get a prototype working of a master auth controller which child controllers (site administration functions) use to secure themselves.
#2

[eluser]xwero[/eluser]
You are using __construct as constructor, Dinner is the php4 compatible constructor.




Theme © iAndrew 2016 - Forum software by © MyBB