×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: Eric Moore
Added: Jan 25, 2022 7:11 AM
Modified: Jan 25, 2022 7:11 AM
Views: 403
Tags: no tags
  1. class Dog
  2. {
  3.     private int $dog_weight = 0;
  4.     private string $dog_breed = "no breed";
  5.     private string $dog_color = "no color";
  6.     private string $dog_name = "no name";
  7.     private string $o; // used for output work
  8.    
  9.     function display_properties()
  10.     {
  11.         $o = "Dog weight is $this->dog_weight. Dog breed is $this->dog_breed. Dog color is $this->dog_color.";
  12.         wro($o);
  13.     }
  14.    
  15.     function get_properties() : string
  16.     {
  17.         return "$this->dog_weight,$this->dog_breed,$this->dog_color";
  18.     }
  19.    
  20.     function speak()
  21.     {
  22.         echo 'bark bark bark!';
  23.     }
  24. }
  25.  
  26. $dog_properties = $chow->get_properties();
  27. list($dog_weight, $dog_breed, $dog_color) = explode(',',$dog_properties );
  28. print "Dog weight is $dog_weight. Dog breed is $dog_breed. Dog Color is $dog_color" ;