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 git.master, git.master_jit, rfc.property-hooks
array(5) { [0]=> string(7) "off ; " [1]=> string(6) "on ; " [2]=> string(6) "on ; " [3]=> string(7) "off ; " [4]=> string(7) "off ; " }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
35.68 ms | 401 KiB | 8 Q