3v4l.org

run code in 300+ PHP versions simultaneously
<?php class C { private $s; public function __construct($s) { $this->s = $s; } protected function getS() { return $this->s; } } class C1 extends C { function do() { echo $this->getS(); echo $this->s; } } $c1 = new C1(); $c1->do();
Output for 7.1.0 - 7.1.25, 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, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught ArgumentCountError: Too few arguments to function C::__construct(), 0 passed in /in/JnOvh on line 20 and exactly 1 expected in /in/JnOvh:5 Stack trace: #0 /in/JnOvh(20): C->__construct() #1 {main} thrown in /in/JnOvh on line 5
Process exited with code 255.
Output for 7.0.0 - 7.0.33
Warning: Missing argument 1 for C::__construct(), called in /in/JnOvh on line 20 and defined in /in/JnOvh on line 5 Notice: Undefined variable: s in /in/JnOvh on line 6 Notice: Undefined property: C1::$s in /in/JnOvh on line 16
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.38
Parse error: syntax error, unexpected 'do' (T_DO), expecting identifier (T_STRING) in /in/JnOvh on line 14
Process exited with code 255.

preferences:
230.53 ms | 402 KiB | 293 Q