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);

preferences:
28.36 ms | 411 KiB | 6 Q