Last active
November 10, 2020 23:08
-
-
Save RickardAhlstedt/4deabe299a84672db8875041ed911dee to your computer and use it in GitHub Desktop.
Single Inheritance-example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Dependencies.. */ | |
class Person { | |
public $sName; | |
protected $iAge; | |
private $mPhone; | |
public function talk() { ... } | |
protected function walk() { ... } | |
private function swim() { ... } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class John extends Person { | |
/* | |
Since John is extending the person-class, this mean that John becomes a child-class. | |
And this mean that John will inherit all public and protected properties and methods from the parent-class( Person.php) | |
So John will have the following props and methods: | |
public $sName; | |
protected $iAge; | |
public function talk(){} | |
protected function walk(){} | |
This will not inherit the private props and methods. | |
*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment