3v4l.org

run code in 500+ PHP versions simultaneously
<?php class SkipProtectedPropertyOnNonFinalClass { protected int $value = 5; public function __construct(int $value) { $this->value = $value; } public function getValue() { return $this->value; } } class SomeChild extends SkipProtectedPropertyOnNonFinalClass { public function __construct() { } } $obj = new SomeChild(); echo $obj->getValue();
Output for 8.3.33, 8.4.9 - 8.4.24, 8.5.7 - 8.5.9
5
Output for 7.2.17
Parse error: syntax error, unexpected 'int' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in /in/PNpBG on line 5
Process exited with code 255.

preferences:
63.74 ms | 512 KiB | 5 Q