3v4l.org

run code in 500+ PHP versions simultaneously
<?php class A { private ?string $b = null; public static function newInstance($args){ return new self($args); } public function __construct($b = 'default') { $this->b = $b; } public function test() { echo("Test:" . $this->b . "\n"); } } $a = new A('test'); $a->test(); var_dump(class_exists('\\A')); $b = new ReflectionClass('A'); $c = $b->newInstance(); $c->test(); var_dump(class_exists('\\A'));
Output for 8.1.28 - 8.1.34, 8.2.15 - 8.2.32, 8.3.2 - 8.3.33, 8.4.1 - 8.4.24, 8.5.0 - 8.5.9
Test:test bool(true) Test:default bool(true)

preferences:
520.78 ms | 854 KiB | 4 Q