Skip to content

Instantly share code, notes, and snippets.

@RickardAhlstedt
Last active November 10, 2020 23:08
Show Gist options
  • Save RickardAhlstedt/4deabe299a84672db8875041ed911dee to your computer and use it in GitHub Desktop.
Save RickardAhlstedt/4deabe299a84672db8875041ed911dee to your computer and use it in GitHub Desktop.
Single Inheritance-example
<?php
/* Dependencies.. */
class Person {
public $sName;
protected $iAge;
private $mPhone;
public function talk() { ... }
protected function walk() { ... }
private function swim() { ... }
}
<?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