How to call parent function from instance of child?

前端 未结 6 2075
青春惊慌失措
青春惊慌失措 2021-02-18 17:57

I have model

BaseUser.class.php
User.class.php
UserTable.class.php

In user Class I have been override the delete function

6条回答
  •  星月不相逢
    2021-02-18 18:58

    I found this thread on codingforums. What it says (and I tend to agree with them) is that if you have an overridden function/method in a child class, an instance of that object will ALWAYS call the child method.

    The parent keyword is akin to $this or self and can only be called from within the class itself.

    If you want a child object to be able to call the parent method, just create another method

    function parentExample() { 
        parent::example(); 
    }
    

    which only calls the parent method.

提交回复
热议问题