Skip to content

Instantly share code, notes, and snippets.

@dimaqw
Created August 22, 2017 23:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dimaqw/fb6c5c315800db1bac151782e1c8113c to your computer and use it in GitHub Desktop.
Save dimaqw/fb6c5c315800db1bac151782e1c8113c to your computer and use it in GitHub Desktop.
<?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