3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php final class Time { private $hours, $minutes; public function __construct($hours, $minutes) { $this->hours = (int) $hours; $this->minutes = (int) $minutes; } public static function fromString($time) { list($hours, $minutes) = explode($time, ':', 2); return new static($hours, $minutes); } public static function fromString2($time) { list($hours, $minutes) = explode($time, ':', 2); return new self($hours, $minutes); } } var_dump(Time::fromString('10:45')); var_dump(Time::fromString2('10:45'));
Output for 5.3.0 - 7.2.0
Notice: Undefined offset: 1 in /in/qveIb on line 15 object(Time)#1 (2) { ["hours":"Time":private]=> int(0) ["minutes":"Time":private]=> int(0) } Notice: Undefined offset: 1 in /in/qveIb on line 21 object(Time)#1 (2) { ["hours":"Time":private]=> int(0) ["minutes":"Time":private]=> int(0) }
Output for 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_STATIC, expecting T_STRING or T_VARIABLE or '$' in /in/qveIb on line 16
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_STATIC, expecting T_STRING or T_VARIABLE or '$' in /in/qveIb on line 16
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_CLASS in /in/qveIb on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_CLASS in /in/qveIb on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/qveIb on line 3
Process exited with code 255.