3v4l.org

run code in 300+ PHP versions simultaneously
<?php class C { public int $value; } $c = new C(); var_dump(isset($c->value)); // false $c->value = 5; var_dump($c->value); //5 unset($c->value); //var_dump($c->value); //Error: Typed property C::$value must not be accessed before initialization var_dump(isset($c->value)); // false $c->value = 5; $c->value = null; //error
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
bool(false) int(5) bool(false) Fatal error: Uncaught TypeError: Cannot assign null to property C::$value of type int in /in/VUVD1:15 Stack trace: #0 {main} thrown in /in/VUVD1 on line 15
Process exited with code 255.
Output for 7.4.0 - 7.4.33
bool(false) int(5) bool(false) Fatal error: Uncaught TypeError: Typed property C::$value must be int, null used in /in/VUVD1:15 Stack trace: #0 {main} thrown in /in/VUVD1 on line 15
Process exited with code 255.

preferences:
127.5 ms | 401 KiB | 121 Q