3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $resource; public function __construct($path) { $this->resource = fopen($path, 'rb'); } public function __destruct() { fwrite(STDOUT, sprintf('BYE BYE %s%s', get_class($this), PHP_EOL)); } } class Bar { private $cl; private $resource; public function __construct($path) { $this->resource = fopen($path, 'rb'); $this->cl = function () {}; } public function __destruct() { fwrite(STDOUT, sprintf('BYE BYE %s%s', get_class($this), PHP_EOL)); } } function get_path($resource) { $ctx = stream_get_meta_data($resource); return $ctx['uri']; } $foo = new Foo(__FILE__); $bar = new Bar(__FILE__); unset($bar); unset($foo);
Output for 7.0.0 - 7.0.23, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.27, 8.4.1 - 8.4.14
BYE BYE Foo BYE BYE Bar

preferences:
160.5 ms | 408 KiB | 5 Q