3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface IErrorManager { public function ariseFatal($message); public function ariseWarning($message); public function ariseNotice($message); } interface ILexer { public function getTokens(); public function tokenize($input); } interface IParser { public function parse($input); } interface IParseResult { public function getDefintion(); public function getName(); public function getConstants(); } interface ICompiler { public function compile($input); } class ErrorManager implements IErrorManager { public function ariseFatal($message) { $this->triggerError($message, E_USER_FATAL); } public function ariseWarning($message) { $this->triggerError($message, E_USER_WARNING); } public function ariseNotice($message) { $this->triggerError($message, E_USER_NOTICE); } private function triggerError($message, $type) { trigger_error((string)$message, (int)$type); } } abstract class CompilerElement { private $errorManager; protected function getErrorManager() { return $this->errorManager; } protected function __construct(IErrorManager $errorManager) { $this->errorManager = $errorManager; } } class Lexer extends CompilerElement implements ILexer { private $tokens = array(); public function getTokens() { return $this->tokens; } public function tokenize($input) { if (!is_string($input)) { $this->getErrorManager()->ariseFatal(get_class($this).'::parse expects parameter 1 to be string. '.gettype($input).' given.'); } } public function __construct(IErrorManager $errorManager) { parent::__construct($errorManager); } } class Parser extends CompilerElement implements IParser { private $lexer; public function parse($input) { if (!is_string($input)) { $this->getErrorManager()->ariseFatal(get_class($this).'::parse expects parameter 1 to be string. '.gettype($input).' given.'); } } public function __construct(ILexer $lexer, IErrorManager $errorManager) { parent::__construct($errorManager); $this->lexer = $lexer; } } class ParseResult extends CompilerElement implements IParseResult { private $definition; private $name; private $constants; public function getDefinition() { return $this->definition; } public function getName() { return $this->name; } public function getConstants() { return $this->constants; } public function __construct($definition, $name, array $constants, IErrorManager $errorManager) { parent::__construct($errorManager); if (!is_string($definition)) { $this->getErrorManager()->ariseFatal(get_class($this).'::__construct expects parameter 1 to be string. '.gettype($definition).' given.'); } if (!is_string($name)) { $this->getErrorManager()->ariseFatal(get_class($this).'::__construct expects parameter 2 to be string. '.gettype($name).' given.'); } $this->definition = $definition; $this->name = $name; $this->constants = $constants; } } class Compiler implements ICompiler { private $parser; const INTENDATION_CHAR = "\t"; public function compile($input) { $parseResult = $this->parser->parse($input); $return = $parseResult->getDefinition().' '.$parseResult->getName().' {'.PHP_EOL; foreach ($parseResult->getConstants() as $name => $value) { $return .= Compiler::INTENDATION_CHAR.'const '.$name.' = '.$value.PHP_EOL; } $return .= Compiler::INTENDATION_CHAR.'private function __construct() {}'.PHP_EOL; $return .= '}'; return $return; } public function __construct(IParser $parser) { $this->parser = $parser; } } $enumCode =<<< PHP enum MyEnum { Item1, Item2, Item3 } PHP;

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.0.0beta10.0120.00616.73
8.0.0alpha30.0090.01216.61
8.0.0alpha20.0090.00916.82
8.0.0alpha10.0140.00416.57
7.4.80.0080.01319.39
7.4.70.0100.00716.60
7.4.60.0080.00816.57
7.4.50.0000.00616.42
7.4.40.0120.00616.54
7.4.30.0170.00016.42
7.3.200.0110.00616.30
7.3.190.0060.00916.46
7.3.180.0100.00716.47
7.3.170.0060.00916.52
7.3.160.0160.00716.47
7.2.320.0060.01116.57
7.2.310.0070.01316.36
7.2.300.0100.00716.26
7.2.290.0060.01516.35
5.4.210.3330.03719.16
5.4.200.3030.03719.19
5.4.190.3030.03319.09
5.4.180.3300.03718.97
5.4.170.3230.03719.05
5.4.160.3400.03718.96
5.4.150.2670.03719.06
5.4.140.3070.03316.58
5.4.130.3370.03316.56
5.4.120.3530.03316.39
5.4.110.3330.03316.43
5.4.100.3530.04316.52
5.4.90.2870.03016.55
5.4.80.3330.03716.41
5.4.70.3430.03316.46
5.4.60.3330.03316.48
5.4.50.3570.04016.62
5.4.40.3630.03316.54
5.4.30.3570.04016.57
5.4.20.3230.03716.47
5.4.10.3430.03316.53
5.4.00.2570.03715.84
5.3.270.3230.03714.77
5.3.260.3630.04314.68
5.3.250.3070.03314.64
5.3.240.3200.03714.57
5.3.230.3370.04314.77
5.3.220.2670.03714.60
5.3.210.3230.03314.68
5.3.200.3400.03314.56
5.3.190.3370.04014.74
5.3.180.3000.03714.65
5.3.170.3670.03314.71
5.3.160.3570.04014.68
5.3.150.3300.04014.74
5.3.140.3300.04014.84
5.3.130.3430.03714.62
5.3.120.3370.03714.69
5.3.110.3300.04014.68
5.3.100.3100.03714.21
5.3.90.3330.04014.07
5.3.80.3470.03714.01
5.3.70.3170.04314.15
5.3.60.3130.04014.15
5.3.50.3330.03713.93
5.3.40.3500.03014.09
5.3.30.3400.03014.19
5.3.20.3330.03713.83
5.3.10.3370.03313.77
5.3.00.3430.04013.75