1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Inheritance Problem

Discussion in 'PHP' started by Rahul Bose, Oct 2, 2010.

  1. #1
    Hi
    I have three classes.
    Fatal error: Call to a member function froma() on a non-object in

    Where is the error? How can I access object type property?

    I want to use all class over the one class ( main class).
    for example:
    $m->Config->get();
    $m->Database->query("Select * From table");
    $m->Input->getPost();

    What is your suggestions?
     
    Rahul Bose, Oct 2, 2010 IP
  2. po_taka

    po_taka Peon

    Messages:
    14
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    i dont know is it possible to do double extend, u need
    class main extend class A, class B { ... }

    1st option:
    use __call()

    2nd

    class main extend class a { .... }
    class a extend class b { ... }
    class b { ... }
     
    po_taka, Oct 2, 2010 IP
  3. stOK

    stOK Active Member

    Messages:
    114
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #3
    First I believe you are using php 4xx. __construct in php4 is not constructor. That's why $a and $b not initialized to objects.
    Second if you were using php 5+ you would end up in core dump. Coz you make stack overflow.
    main::__construct calls a's and b's implicit constructors when you use new and teh new()'s call main::__construct coz a and b extend main class.
     
    stOK, Oct 2, 2010 IP