3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace ECommerce { use Exception; class CreditCardValidationException extends Exception { } class CreditCardNumber { private $digits; public function __construct($digits) { $this->digits = $digits; if (!$this->_validate()) { throw new CreditCardValidationException('Checksum failed'); } } private function _validate() { for($i=0,$t=0;$i<16;$i+=2) $t+=(($d=((int)$this->digits{$i}*2))>9?array_sum(array_map('intval',str_split(strval($d)))):$d)+$this->digits{$i+1}; return(bool)($t%10===0); } } } namespace { try { $ccn = new ECommerce\CreditCardNumber('4417123456789113'); } catch (ECommerce\CreditCardValidationException $exception) { echo 'Invalid credit card number'; } finally if (!isset($exception)) { echo 'VALID credit card number'; } }

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)
5.4.250.0090.04012.42
5.4.240.0040.03812.39
5.4.230.0060.03912.38
5.4.220.0050.04012.39
5.4.210.0070.03412.39
5.4.200.0070.03812.38
5.4.190.0060.03712.38
5.4.180.0060.03612.38
5.4.170.0050.03712.39
5.4.160.0040.04012.38
5.4.150.0050.03812.38
5.4.140.0070.03512.07
5.4.130.0040.04512.05
5.4.120.0070.04012.02
5.4.110.0040.03612.01
5.4.100.0040.03612.01
5.4.90.0050.03712.01
5.4.80.0070.03512.01
5.4.70.0020.04012.01
5.4.60.0040.03812.01
5.4.50.0070.03612.01
5.4.40.0080.03312.00
5.4.30.0050.03911.99
5.4.20.0040.04211.99
5.4.10.0050.03611.99
5.4.00.0090.03211.48
5.3.280.0090.03912.70
5.3.270.0050.03912.73
5.3.260.0050.04112.72
5.3.250.0060.04812.71
5.3.240.0040.04212.72
5.3.230.0080.03712.71
5.3.220.0110.03912.68
5.3.210.0040.04212.68
5.3.200.0080.03612.68
5.3.190.0070.04012.68
5.3.180.0070.04012.67
5.3.170.0050.03712.67
5.3.160.0020.03912.67
5.3.150.0050.03812.68
5.3.140.0080.03512.66
5.3.130.0080.03712.66
5.3.120.0080.04312.66
5.3.110.0070.03812.66
5.3.100.0040.03912.12
5.3.90.0090.03712.09
5.3.80.0100.03212.08
5.3.70.0120.03412.07
5.3.60.0040.03812.06
5.3.50.0030.03912.00
5.3.40.0080.03512.00
5.3.30.0110.04611.98
5.3.20.0080.03811.75
5.3.10.0070.03411.71
5.3.00.0030.04211.70

preferences:
141.73 ms | 1394 KiB | 7 Q