3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { public function __construct() { $this->fp = fopen(__FILE__, 'r'); } public function __destruct() { fclose($this->fp); } public function __clone() { $this->fp = fopen(__FILE__, 'r'); } public function getFp() { return $this->fp; } } $t = new Test; var_dump($t->getFp()); // works $c = clone $t; var_dump($c->getFp()); // works var_dump((clone $t)->getFp()); // dtor'd before being accessed?
Output for 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
Deprecated: Creation of dynamic property Test::$fp is deprecated in /in/jQ0Pi on line 7 resource(5) of type (stream) resource(6) of type (stream) resource(7) of type (Unknown)
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 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.34
resource(5) of type (stream) resource(6) of type (stream) resource(7) of type (Unknown)

preferences:
102.77 ms | 1518 KiB | 4 Q