3v4l.org

run code in 300+ PHP versions simultaneously
<?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 - 5.6.25, 7.0.0 - 7.0.20, 7.1.0 - 7.1.7, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.27, 8.3.0 - 8.3.16, 8.4.1 - 8.4.3
I'm alive! I'm dead now :( I'm alive! Name of the animal: cat I'm dead now :(

preferences:
122.46 ms | 408 KiB | 5 Q