3v4l.org

run code in 300+ PHP versions simultaneously
<?php class NullableA { private function __construct() {} public ?string $string; public static function &string(?string $defaultValue = null) { $type = new self; $type->string = $defaultValue; return $type->string; // type is garbage collected } } class NullableB { private static $antiGarbageCollect = []; private function __construct() {} public ?string $string; public static function &string(?string $defaultValue = null) { $type = new self; self::$antiGarbageCollect[] = $type; $type->string = $defaultValue; return $type->string; } } $a =& NullableA::string(); $a = 123; var_dump($a); $b =& NullableB::string(); $b = 123; var_dump($b);
Output for git.master, git.master_jit, rfc.property-hooks
int(123) string(3) "123"

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
122.56 ms | 405 KiB | 5 Q