3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ExpressionCalculator { public function calc($expression) { $operands = array(); while (($token = strtok($expression, ' ')) !== false) { if (isOperator($token)) { $rightOperand = array_pop($operands); $leftOperand = array_pop($operands); $result = $this->execute($token, $leftOperand, $rightOperand); array_push($operands, $result); continue; } array_push($operands, $token); } return $result; } } $calc = new ExpressionCalculator(); echo $calc->calc('5 1 2 + 4 * + 3 -'); // 14
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Call to undefined function isOperator() in /in/ZE8NM:9 Stack trace: #0 /in/ZE8NM(26): ExpressionCalculator->calc('5 1 2 + 4 * + 3...') #1 {main} thrown in /in/ZE8NM on line 9
Process exited with code 255.

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:
44.49 ms | 401 KiB | 8 Q