- Output for 8.1.32, 8.2.0 - 8.2.28, 8.3.0 - 8.3.22, 8.4.1 - 8.4.8
- Typed static property C::$prop must not be accessed before initialization Access to undeclared static property C::$nonExistent string(7) "default" string(7) "default"
<?php
class C {
public static string $prop;
}
try {
var_dump(C::$prop);
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
try {
var_dump(C::$nonExistent);
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
var_dump(C::$prop ?? 'default');
var_dump(C::$nonExistent ?? 'default');