Skip to content

Instantly share code, notes, and snippets.

@levidurfee levidurfee/Boy.php
Created Jan 11, 2017

Embed
What would you like to do?
Inheritance in PHP
<?php
class Boy extends Person {
public function washHands() {
echo "I don't wash my hands...";
}
}
<?php
interface PersonInterface {
public function eat($food);
}
interface BathroomInterface {
public function poop();
public function pee();
public function washHands();
}
class Person implements PersonInterface, BathroomInterface {
public $name;
public $age;
public function __construct($name, $age)
{
$this->name = $name;
$this->age = $age;
}
public function eat($food) {
echo $this->name . ' is eating ' . $food;
}
public function poop() {
echo "I feel better.";
}
public function pee() {
echo "Glad I didn't pee my pants";
}
public function washHands() {
echo "Yes, I wash my hands.";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.