Home  >  Article  >  php教程  >  How to overload parent class methods in PHP object-oriented subclasses

How to overload parent class methods in PHP object-oriented subclasses

WBOY
WBOYOriginal
2016-08-04 08:57:111023browse

Because functions with the same name cannot exist in PHP, methods with the same name cannot be defined in the same class. The overloading mentioned here means that a method with the same name as the parent class can be defined in a subclass to override the method inherited from the parent class.


Overloading parent class methods in subclasses


<?php
class Person{
                                        
             public $name;
                                          
          public function
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn