Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2004
    Location
    Bucharest
    Posts
    37

    Post Unanswered: php class extended

    class.parent.php

    class.child1.php (extends class.parent.php)
    class.child2.php (extends class.parent.php)
    class.child3.php (extends class.parent.php)

    in class.action_parent.php (extends class.parent.php) i want to be able to user all the methods from childs without being forced to do something like:

    $child1 = new CHILD1;
    $child1 -> ....

    i want to have all the methods available in $this->

    does this makes sense to anyone? please tell me what are the options here.
    thanks

  2. #2
    Join Date
    Mar 2007
    Location
    636f6d7075746572
    Posts
    770
    I heavily expect that you are NOT writing your OOP very well if this is the case. It seems that you should extend your child NOT your parent in order to use those methods.
    You CANNOT use a method of a child that has not been instantiated UNLESS that method is static. In your case :

    $blah = new action_parent();

    child does NOT exist yet because you don't have an instance and have extended from the parent class.

    Please provide the PHP code for what you are trying to do/extend.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •