Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.96 KB | None | 0 0
  1. <?php
  2.  
  3. function enhancedEcho () {
  4.     echo implode("<br/>", func_get_args());
  5. }
  6.  
  7. /**
  8.  * Created by PhpStorm.
  9.  * User: Thomas
  10.  * Date: 4/22/2018
  11.  * Time: 9:31 PM
  12.  */
  13. interface MyApiInterface {
  14.     public static function setName (string $name);
  15. }
  16.  
  17. class Primate implements MyApiInterface {
  18.     protected static $staticName = "Not so badass mofo";
  19.  
  20.     /**
  21.      * @param string $name
  22.      */
  23.     public static function setName(string $name) {
  24.         self::$staticName = $name;
  25.     }
  26. }
  27.  
  28. class Animal extends Primate {
  29.     protected $name = '';
  30.     function __construct(string $name) {
  31.         $this->name = $name;
  32.     }
  33. }
  34.  
  35. class Dog extends Animal {
  36.     function bark() {
  37.         echo $this->name;
  38.     }
  39.     static function barkSoftly() {
  40.         echo self::$staticName;
  41.     }
  42. }
  43.  
  44. $inst = new Dog("Some badass mofo");
  45. $inst->bark();
  46.  
  47. echo "<br/>";
  48.  
  49. enhancedEcho("Mememachine", "Secondmememachine");
  50.  
  51. echo "<br/>";
  52.  
  53. Dog::barkSoftly();
  54.  
  55. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement