3v4l.org

run code in 300+ PHP versions simultaneously
<?php class x { private static self $x; static function getInstance() { // all good return self::$x ??= new self(); } static function getInstance2() { // Not ok : cannot access before initialisation return self::$x = self::$x ?? new self(); } static function getError() { // Not ok : cannot access before initialisation if (!self::$x instanceof self) { self::$x = new self(); } return self::$x; } }

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
152.5 ms | 1453 KiB | 8 Q