3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Animal { private $name = "No-name animal"; public function __construct($name) { echo "I'm alive!\n"; $this->name = $name; } public function test(){ echo "Name of the animal: " . $this->name ."\n"; } public function __destruct() { echo "I'm dead now :(\n"; } } $animal = new Animal("Bob"); $animal=null; $animal2=new Animal("cat"); $animal2->test(); ?>
Output for 5.6.0 - 7.2.0
I'm alive! I'm dead now :( I'm alive! Name of the animal: cat I'm dead now :(