Created
August 22, 2017 23:09
-
-
Save dimaqw/fb6c5c315800db1bac151782e1c8113c to your computer and use it in GitHub Desktop.
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 Animal { | |
public $name; | |
function __construct($name){ | |
$this->name = $name; | |
} | |
public function getName (){ | |
return $this->name; | |
} | |
} | |
class Cat extends Animal { | |
public function meow (){ | |
return "Cat {$this->name} is saying meow"; | |
} | |
} | |
$cat = new Cat ('garfield'); | |
var_dump($cat->getName () === 'garfield'); // true; | |
echo PHP_EOL; | |
var_dump($cat->meow () === 'Cat garfield is saying meow'); // true; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment