daily pastebin goal
27%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top