Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * животное
- */
- class Animal
- {
- private $name;
- /**
- * создать животное
- * @param string $name имя
- */
- public function __construct($name)
- {
- $this->name = $name;
- }
- /**
- * узнать имя
- * @return string $name
- */
- public function getName()
- {
- return $this->name;
- }
- }
- /**
- * кот
- */
- class Cat extends Animal
- {
- /**
- * @return string «Cat {name} is saying meow»
- */
- public function meow()
- {
- return 'Cat ' . $this->getName() . ' is saying meow';
- }
- }
- $cat = new Cat ('garfield');
- echo $cat->getName() . '<br>';
- echo $cat->meow();
Add Comment
Please, Sign In to add comment