3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class C { private $s; public function __construct($s) { $this->s = $s; } protected function getS() { return $this->s; } } class C1 extends C { public function __get($name) { $value = 'wanted:'.$name; $this->$name = $value.',got it again'; return $value; } public function __construct($s1) { parent::__construct($s1); } function doStuff() { echo $this->getS()."\n"; echo $this->s."\n"; echo $this->s."\n"; } } $c1 = new C1('foo'); $c1->doStuff();
Output for 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
foo Deprecated: Creation of dynamic property C1::$s is deprecated in /in/KuTGX on line 16 wanted:s wanted:s,got it again
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28
foo wanted:s wanted:s,got it again

preferences:
270.92 ms | 403 KiB | 327 Q