Q:
         
         
            
               What type of inheritance that PHP supports? Provide an example.
            
                      
         
             Answer
                        PHP supports single level inheritance.
Inheriting a class would mean creating a new class with all functionality of the existing class in addition to some more. The created class is called as a subclass of the parent class. Parent is a keyword which we use to access members of a parent class. Inheritance is usually defined by using the keyword “Extend”. $this is used a reference to the calling object. Inheritance avoids redundancy of code.
Example:
Class employee extends manager : Here Employee is a subclass of manager.
Echo $this->name can be used to echo variable name of the parent class.
          
         
         
         
             View answer
             Workspace
             Report Error
             Discuss