Guest User

Untitled

a guest
Jun 13th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. <?php
  2.  
  3. class Person {
  4. public $first_name = '';
  5. public $last_name = '';
  6. public $eye_color = '';
  7. public $actions = array();
  8. public $person2;
  9.  
  10.  
  11. public function __construct($first_name, $last_name, $eye_color) {
  12. $this->first_name = $first_name;
  13. $this->last_name = $last_name;
  14. $this->eye_color = $eye_color;
  15.  
  16. }
  17.  
  18. public function trot() {
  19. $this->actions[] = 'Trotting';
  20. }
  21.  
  22. public function eat($food = 'grapes') {
  23. $this->actions[] = $this->first_name . ' is eating ' . $food;
  24. }
  25.  
  26. private function pee() {
  27. $this->actions[] = 'Went pee.';
  28. }
  29.  
  30. public function urge_to_pee() {
  31. echo 'I HAVE TO GO PEE';
  32. $this->pee();
  33. }
  34.  
  35. }
  36.  
  37.  
  38. /**
  39. * Below here is not part of the class
  40. */
  41.  
  42. $person = new Person('Bill', 'Failing', 'Brown');
  43.  
  44. $person->trot();
  45. $person->trot();
  46. $person->eat('Cheezburger');
  47. $person->urge_to_pee();
  48.  
  49. print_r($person->actions);
  50.  
  51. ?>
Add Comment
Please, Sign In to add comment