3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Timer { private $_state; private $_date; public function __construct($state, \DateTime $date) { $this->_state = $state; $this->_date = clone $date; } public function getType() { return $this->_state; } public function getInterval() { return (new \DateTime('2015-01-01'))->diff(clone $this->_date); } public function isPositive() { return !(bool) $this->getInterval()->invert; } public function isNegative() { return (bool) $this->getInterval()->invert; } } $timer = new Timer('lalala', new \DateTime('2015-01-01')); var_dump( $timer->isPositive(), $timer->isNegative() );
based on 0iepG
Output for 5.4.0 - 7.2.0
bool(true) bool(false)
Output for 5.3.0 - 5.3.29
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/nQjDi on line 20
Process exited with code 255.
Output for 5.1.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/nQjDi on line 7 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/nQjDi on line 20 Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/nQjDi on line 20
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/nQjDi on line 7 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/nQjDi on line 20 Parse error: parse error, unexpected T_OBJECT_OPERATOR in /in/nQjDi on line 20
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/nQjDi on line 4
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_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/nQjDi on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/nQjDi on line 4
Process exited with code 255.