3v4l.org

run code in 300+ PHP versions simultaneously
<?php class CommandFactory { private $commandMappings; public function __construct(string $mappingFilename = 'default.json') { $mappingsJSON = file_get_content($mappingFilename); $this->commandMappings = json_decode("{ 'command' : { 'SYSTEMS' : { 'OS1' : { 'Version' : 'command string', 'Version2' : 'command string', }, 'OS2' : { 'Version' : 'command string', 'Version' : 'command string' }, 'COMMANDOPTIONS' : ['var1', 'var2', 'var3'], }, 'add-Firewall' : { 'SYSTEMS' : { 'Ubuntu' : { '14' : 'command string', '11' : 'command string', }, 'Redhat' : { '13' : 'command string', '11' : 'command string' }, 'COMMANDOPTIONS' : ['port',], }, }", true); } public function getCommand(string $command, array $options): Command { $commandArray = $this->commandMappings[$command]; return new Command($commandArray, $options); } } class Command { private $options; private $mapping; public function __construct($mappings, $options) { // check if options are are valid // potentially map in options here? } public function view(string $os, $version): string { // validate $os and $version $command = $this->mapping['SYSTEMS'][$os][$version] //$command = str_replace(array_keys($options), $options, $command); return $command; } } // usage $factory = new CommandFactory(); $firewallCommand = $factory->getCommand('add-Firewall', array['port' => 23]); echo $firewallCommand->view('Ubuntu', '11');

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)
7.1.70.0030.01717.09
7.1.60.0260.01934.96
7.1.50.0270.01734.60
7.1.40.0330.00834.25
7.1.30.0360.00834.32
7.1.20.0290.01334.69
7.1.10.0140.00716.31
7.1.00.0140.00816.46
7.0.200.0060.01316.54
7.0.190.0140.00616.26
7.0.180.0110.01415.84
7.0.170.0120.01016.11
7.0.160.0080.01116.11
7.0.150.0050.01516.11
7.0.140.0100.01116.27
7.0.130.0100.01016.24
7.0.120.0070.01316.08
7.0.110.0110.00816.13
7.0.100.0080.01316.04
7.0.90.0150.00816.01
7.0.80.0060.01616.10
7.0.70.0110.00916.32
7.0.60.0070.01215.96
7.0.50.0100.01015.96
7.0.40.0030.01616.21
7.0.30.0090.01116.37
7.0.20.0060.01316.12
7.0.10.0050.01416.30
7.0.00.0100.01216.25

preferences:
138 ms | 1394 KiB | 7 Q