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.5.8
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:
40.56 ms | 484 KiB | 4 Q