Instantly share code, notes, and snippets.

Embed
What would you like to do?
PHP Magic Methods Program (4)
<?php
class Dog {
private $name;
public function __construct($name) {
echo "object constructed! <br>";
$this->name = $name;
}
public function bark() {
echo "Bark! <br >";
}
public function __destruct() {
echo "object destructed! <br>";
}
}
$dog = new Dog("Arnold");
$dog->bark();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment