3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Expressions { // Prerequisites for examples below public $a = 1; public static $b = 3; function bar() {} static function baz() {} function foo() { // Prerequisites for examples below $a = 1; $b = 2; $x = [1, 2]; file_put_contents('/tmp/a.php', ''); // Examples based on php-parser expression types // Using as few variables within the expressions themselves as the parser allows, to avoid false-positives static $arrowFunction = fn() => 1; static $assign = ($a = 1); static $assignOpAdd = ($a += 1); static $assignOpAnd = ($a &= 1); static $assignOpConcat = ($a .= "b"); static $assignOpDiv = ($a /= 2); static $assignRef = ($a =& $b); static $castInt = (int)"1"; static $clone = clone (new stdClass()); static $closure = function () { return 1; }; static $closureUse = function () use ($x) {}; static $empty = empty(1); static $encapsed = "Value: $a"; static $errorSuppress = @new stdClass(); static $eval = eval('1+1;'); static $funcCall = strlen('x'); static $include = include '/tmp/a.php'; static $instanceof = new stdClass() instanceof self; static $isset = isset($x); static $list = [[$a, $b] = [1, 2]]; static $match = match (1) {1 => 'a', default => 'b'}; static $methodCall = (new Expressions())->bar(); static $nullsafeMethodCall = (new Expressions())?->bar(); static $postInc = $a++; static $print = print ''; static $shellExec = `whoami`; // expected warning due to sandbox environment static $staticCall = self::baz(); static $staticPropertyFetch = self::$b; static $variable = $a; // These are invalid but give a different error static $nullsafePropertyFetch = (new Expressions())?->a; static $propertyFetch = (new Expressions())->a; } } $expr = new Expressions(); $expr->foo();

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.5.10.0110.00616.94
8.5.00.0120.00922.76
8.4.160.0130.00925.02
8.4.150.0120.00117.00
8.4.140.0370.00717.64
8.4.130.0380.00717.55
8.4.120.0380.00818.00
8.4.110.0380.00817.84
8.4.100.0350.01418.05
8.4.90.0400.01117.61
8.4.80.0350.01018.01
8.4.70.0330.01317.47
8.4.60.0400.01117.75
8.4.50.0420.00917.68
8.4.40.0390.01017.75
8.4.30.0410.00717.39
8.4.20.0410.00617.44
8.4.10.0390.00817.46
8.3.290.0110.01020.69
8.3.280.0130.00820.54
8.3.270.0350.00916.73
8.3.260.0380.00716.59
8.3.250.0310.01216.81
8.3.240.0360.00716.67
8.3.230.0350.00816.66
8.3.220.0370.00716.91
8.3.210.0390.00516.68
8.3.200.0340.00916.75
8.3.190.0370.00816.54
8.3.180.0370.00816.71
8.3.170.0390.00916.47
8.3.160.0380.01016.92
8.3.150.0380.01016.85
8.3.140.0340.01216.82
8.3.130.0310.01116.73
8.3.120.0300.01116.64
8.3.110.0330.00916.47
8.3.100.0370.01016.79
8.3.90.0390.01216.78
8.3.80.0390.00917.00
8.3.70.0360.00916.49
8.3.60.0380.00816.82
8.3.50.0350.01116.76
8.3.40.0360.00917.83
8.3.30.0280.00917.59
8.3.20.0270.00917.72
8.3.10.0300.00717.70
8.3.00.0310.00817.32
8.2.300.0110.01220.05
8.2.290.0260.01016.39
8.2.280.0300.00716.78
8.2.270.0310.00716.64
8.2.260.0310.00816.26
8.2.250.0290.01016.42
8.2.240.0290.00816.75
8.2.230.0320.00915.90
8.2.220.0300.00916.38
8.2.210.0320.01016.69
8.2.200.0260.00816.59
8.2.190.0290.01116.40
8.2.180.0310.00716.55
8.2.170.0330.00617.44
8.2.160.0300.00817.57
8.2.150.0320.00817.24
8.2.140.0280.01017.27
8.2.130.0310.00917.44
8.2.120.0340.00717.50
8.2.110.0320.00617.22
8.2.100.0340.00717.11
8.2.90.0270.01117.36
8.2.80.0300.00817.19
8.2.70.0300.01117.17
8.2.60.0300.00717.35
8.2.50.0280.00917.16
8.2.40.0310.00817.27
8.2.30.0300.00917.21
8.2.20.0280.00917.00
8.2.10.0240.01217.22
8.2.00.0290.00917.02
8.1.340.0130.00917.54

preferences:
38.39 ms | 403 KiB | 5 Q