Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Person {
- public $first_name = '';
- public $last_name = '';
- public $eye_color = '';
- public $actions = array();
- public $person2;
- public function __construct($first_name, $last_name, $eye_color) {
- $this->first_name = $first_name;
- $this->last_name = $last_name;
- $this->eye_color = $eye_color;
- }
- public function trot() {
- $this->actions[] = 'Trotting';
- }
- public function eat($food = 'grapes') {
- $this->actions[] = $this->first_name . ' is eating ' . $food;
- }
- private function pee() {
- $this->actions[] = 'Went pee.';
- }
- public function urge_to_pee() {
- echo 'I HAVE TO GO PEE';
- $this->pee();
- }
- }
- /**
- * Below here is not part of the class
- */
- $person = new Person('Bill', 'Failing', 'Brown');
- $person->trot();
- $person->trot();
- $person->eat('Cheezburger');
- $person->urge_to_pee();
- print_r($person->actions);
- ?>
Add Comment
Please, Sign In to add comment