3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Condition { private $value; private $variable = false; public function setCondition($new_value) { switch ($new_value) { case 'cond2': $this->variable = true; break; case 'cond4': $this->variable = false; break; } $this->value = $new_value; } public function getCondition() { return $this->value; } public function isVariableSet() { return ($this->variable === true); } } $conditions = array( 'cond1', 'cond2', 'cond3', 'cond4','cond5' ); $cond = new Condition(); $results = array(); $setCondGetVariable = function($condition) use($cond) { $cond->setCondition($condition); if ($cond->isVariableSet() == true) { $toggle = 'on'; } else { $toggle = 'off'; } return $toggle.' ; '; } $results = array_map($setCondGetVariable, $conditions); var_dump($results);
Output for 5.4.0 - 5.4.29
Parse error: syntax error, unexpected '$results' (T_VARIABLE) in /in/i2nBB on line 46
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_VARIABLE in /in/i2nBB on line 46
Process exited with code 255.

preferences:
173.15 ms | 1395 KiB | 66 Q