How to call parent function from instance of child?

前端 未结 6 2083
青春惊慌失措
青春惊慌失措 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:37

    I think you are looking for the PHP parent functions:

    \n";
        }
    }
    
    class B extends A {
        function example() {
        echo "I am B::example() and provide additional functionality.
    \n"; parent::example(); } } $b = new B; // This will call B::example(), which will in turn call A::example(). $b->example(); ?>

    If your class doesn't have a function called getMyFunction() calling $b->getMyFuction() will call the parent function. If it does, it will call the child function, unless the child function calls the prent function.

提交回复
热议问题