$this->name = 'dog'; $this->age = $age; } public function sayBreed() { echo 'My breed is ' . $this->breed; } // kill the dog // this happens when the object is destroyed public function __destruct() { unset($this->name); } } function say_animal_name($name) { echo 'I am a ' . $name; } function sayDogBreed($breed) { echo 'My breed is ' . $breed; } $dog = new Dog(12); $dog->breed = 'labrador'; $dog->sayName(); echo '<br>'; $dog->sayBreed(); echo '<br>'; echo 'the color is ' . Dog::$color; echo '<br>'; echo 'i have ' . Dog::TEETH . ' teeth';
<?php require_once dirname(__FILE__) . '/Pet.php'; require_once dirname(__FILE__) . '/Dog.php'; $myDog = new Dog("Raya", 4, "Labrador"); $myDog->greet(); $myDog->sayBreed();