3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Php8CompatUtils { private static ?object $logger = null; public static function eq($a, $b): bool { // If both $a and $b are of type strings, compare them as strings if (is_string($a) && is_string($b)) { return $a == $b; // may not be === because php says '42' equals '042' true yet '42' === '042' is false. } // If both $a and $b are numeric strings, compare them as numbers if (is_numeric($a) && is_numeric($b)) { return $a == $b; } // If $a is an empty string and $b is 0, or vice versa, return true if (($a === '' && $b === 0) || ($a === 0 && $b === '')) { return true; } // If $a is a non-numeric string and $b is 0, or vice versa, return true if ((is_string($a) && ($a !== '') && ($b === 0)) || (($a === 0) && is_string($b) && ($b !== ''))) { return true; } // special case '123abc' == 123 .. php 7 casts 123abc to 123, then 123 == 123 results in true. lets mimic that. if ((is_string($a) && ($a !== '') && (is_numeric($b)) && ((bool)$b))) { $number = filter_var($a, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); //"-234.56xyz" return $number == $b; } if (is_numeric($a) && ((bool)$a) && is_string($b) && ($b !== '')) { $number = filter_var($b, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); //"-234.56xyz" return $a == $number; } // If $a is a number and $b is a non-numeric string, cast $a to string and compare if (is_numeric($a) && is_string($b)) { return strval($a) == $b; } // If $b is a number and $a is a non-numeric string, cast $b to string and compare if (is_string($a) && is_numeric($b)) { return $a == strval($b); } if (is_array($a) || is_array($b)) { return static::standardArrayCompare($a, $b); } // If $a and $b are both non-numeric strings, compare them directly, we should return true if they are the same return $a == $b; } public static function gt($a, $b): bool { if (static::eq($a, $b)) { return false; } return $a > $b; } public static function lt($a, $b): bool { if (static::eq($a, $b)) { return false; } return $a < $b; } public static function gte($a, $b): bool { return static::eq($a, $b) || ($a > $b); } public static function lte($a, $b): bool { return static::eq($a, $b) || ($a < $b); } private static function standardArrayCompare($op1, $op2) { if (count($op1) < count($op2)) { return -1; // $op1 < $op2 } elseif (count($op1) > count($op2)) { return 1; // $op1 > $op2 } foreach ($op1 as $key => $val) { if (!array_key_exists($key, $op2)) { return 1; } elseif (static::lt($val, $op2[$key])) { return -1; } elseif (static::gt($val, $op2[$key])) { return 1; } } return 0; // $op1 == $op2 } } $a = [0 => '']; $b = [0 => 0]; var_dump(Php8CompatUtils::eq($a, $b)); var_dump($a == $b);

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.4.30.0160.00319.02
8.4.20.0400.00717.48
8.4.10.0430.00317.34
8.3.160.0060.01316.82
8.3.150.0370.00816.28
8.3.140.0300.01516.48
8.3.130.0280.01416.73
8.3.120.0370.00716.46
8.3.110.0330.00716.52
8.3.100.0450.00016.56
8.3.90.0430.00716.57
8.3.80.0260.01616.36
8.3.70.0370.00816.42
8.3.60.0360.00916.29
8.3.50.0450.00916.42
8.3.40.0320.00617.65
8.3.30.0210.00017.53
8.3.20.0210.00317.64
8.3.10.0280.00317.54
8.3.00.0130.01019.35
8.2.270.0180.01816.77
8.2.260.0220.01616.20
8.2.250.0270.00716.87
8.2.240.0320.00616.50
8.2.230.0250.01416.27
8.2.220.0310.00716.27
8.2.210.0260.01216.53
8.2.200.0340.00316.63
8.2.190.0400.00016.29
8.2.180.0240.01416.57
8.2.170.0340.00717.63
8.2.160.0300.01017.72
8.2.150.0320.00717.64
8.2.140.0360.00417.49
8.2.130.0310.01017.56
8.2.120.0330.00717.59
8.2.110.0290.01117.43
8.2.100.0320.01317.60
8.2.90.0270.01317.71
8.2.80.0340.00417.50
8.2.70.0200.01317.53
8.2.60.0240.00717.58
8.2.50.0180.00617.70
8.2.40.0270.01217.57
8.2.30.0290.00717.51
8.2.20.0390.00317.42
8.2.10.0240.01217.57
8.2.00.0220.01417.58
8.1.310.0440.00016.00
8.1.300.0300.00715.99
8.1.290.0270.01016.00
8.1.280.0320.00616.10
8.1.270.0260.01117.23
8.1.260.0320.00516.99
8.1.250.0230.01017.25
8.1.240.0320.00416.96
8.1.230.0240.01217.35
8.1.220.0220.01317.39
8.1.210.0250.01317.28
8.1.200.0290.00617.12
8.1.190.0330.00617.24
8.1.180.0160.01316.95
8.1.170.0150.00517.09
8.1.160.0170.00017.29
8.1.150.0210.00717.13
8.1.140.0150.00517.25
8.1.130.0350.00317.31
8.1.120.0310.00817.23
8.1.110.0280.00617.04
8.1.100.0290.00417.37
8.1.90.0150.00817.25
8.1.80.0520.00316.92
8.1.70.0270.01117.39
8.1.60.0290.00617.54
8.1.50.0300.00717.37
8.1.40.0260.01317.43
8.1.30.0270.00917.46
8.1.20.0230.01317.46
8.1.10.0300.00417.34
8.1.00.0230.00617.05
8.0.300.0260.00316.50
8.0.290.0220.00616.61
8.0.280.0350.00016.58
8.0.270.0260.00916.66
8.0.260.0280.00816.63
8.0.250.0290.00716.68
8.0.240.0340.00316.62
8.0.230.0220.01316.77
8.0.220.0260.01016.58
8.0.210.0240.01116.61
8.0.200.0320.00316.63
8.0.190.0230.01116.84
8.0.180.0300.00716.66
8.0.170.0310.00716.43
8.0.160.0300.00616.65
8.0.150.0270.00316.79
8.0.140.0290.00716.52
8.0.130.0230.01316.77
8.0.120.0290.01216.15
8.0.110.0170.01716.57
8.0.100.0180.01216.53
8.0.90.0440.00316.64
8.0.80.0320.00416.38
8.0.70.0260.00916.66
8.0.60.0250.00716.68
8.0.50.0320.00416.26
8.0.30.0210.01416.52
8.0.20.0210.01416.52
8.0.10.0290.00416.84
8.0.00.0330.00316.83
7.4.330.0270.00816.33
7.4.320.0210.01216.30
7.4.300.0200.01216.30
7.4.290.0340.00216.27
7.4.280.0250.00716.43
7.4.270.0240.00816.30
7.4.260.0320.00316.33
7.4.250.0250.00816.09
7.4.240.0290.00416.10
7.4.230.0260.00616.14
7.4.220.0270.00416.18
7.4.210.0200.01216.17
7.4.200.0200.01216.36
7.4.190.0230.01016.20
7.4.180.0220.01116.36
7.4.160.0230.01016.51
7.4.150.0210.01216.27
7.4.140.0260.00616.13
7.4.130.0290.00316.20
7.4.120.0210.01016.25
7.4.110.0240.00716.43
7.4.100.0170.01416.47
7.4.90.0310.00816.14
7.4.80.0220.01116.07
7.4.70.0190.01316.16
7.4.60.0330.00316.16
7.4.50.0280.00316.03
7.4.40.0230.00316.14
7.4.30.0220.00916.26
7.4.20.0190.01216.20
7.4.10.0210.01116.04
7.4.00.0250.00616.19
7.3.330.0280.00615.53
7.3.320.0310.00415.57
7.3.310.0230.00915.74
7.3.300.0230.00815.84
7.3.290.0270.00415.47
7.3.280.0240.00715.91
7.3.270.0250.00615.88
7.3.260.0220.00915.78
7.3.250.0330.00015.67
7.3.240.0240.00715.80
7.3.230.0190.01215.54
7.3.220.0220.01015.59
7.3.210.0220.01115.63
7.3.200.0330.00915.54
7.3.190.0180.01415.59
7.3.180.0330.00015.89
7.3.170.0330.00416.09
7.3.160.0220.01315.71
7.3.150.0230.01115.60
7.3.140.0280.00615.93
7.3.130.0280.00815.67
7.3.120.0330.00015.50
7.3.110.0280.00715.43
7.3.100.0230.00815.74
7.3.90.0310.00015.84
7.3.80.0280.00415.67
7.3.70.0280.00415.90
7.3.60.0280.00316.03
7.3.50.0330.00015.86
7.3.40.0310.00015.87
7.3.30.0240.00815.88
7.3.20.0250.00417.85
7.3.10.0200.00717.53
7.3.00.0100.00517.75
7.2.340.0150.00915.82
7.2.330.0280.00015.60
7.2.320.0180.00915.73
7.2.310.0260.00315.86
7.2.300.0260.00615.70
7.2.290.0310.00015.83
7.2.280.0290.00015.80
7.2.270.0250.00315.91
7.2.260.0220.00715.64
7.2.250.0210.00515.89
7.2.240.0310.00315.59
7.2.230.0290.00315.82
7.2.220.0200.01215.89
7.2.210.0200.00816.04
7.2.200.0170.00715.95
7.2.190.0260.00316.00
7.2.180.0270.00716.05
7.2.170.0250.00616.06
7.2.160.0160.01615.95
7.2.150.0280.00717.97
7.2.140.0300.00318.02
7.2.130.0260.00018.11
7.2.120.0230.00918.01
7.2.110.0240.00817.88
7.2.100.0210.01117.76
7.2.90.0290.00317.85
7.2.80.0310.00017.92
7.2.70.0250.00917.95
7.2.60.0220.00617.77
7.2.50.0230.00317.91
7.2.40.0170.01417.68
7.2.30.0280.00418.07
7.2.20.0280.00317.82
7.2.10.0230.00917.93
7.2.00.0320.00018.11
7.1.330.0210.00716.94
7.1.320.0220.00616.70
7.1.310.0250.00316.86
7.1.300.0250.00416.73
7.1.290.0310.00316.57
7.1.280.0190.00716.63
7.1.270.0200.00816.90
7.1.260.0210.00816.54
7.1.250.0250.00616.61
7.1.240.0150.01116.95
7.1.230.0150.00917.01
7.1.220.0140.01416.71
7.1.210.0210.00716.77
7.1.200.0260.00316.97
7.1.190.0210.00816.72
7.1.180.0200.00816.77
7.1.170.0250.00316.74
7.1.160.0230.00616.87
7.1.150.0260.00416.59
7.1.140.0290.00616.73
7.1.130.0240.00716.81
7.1.120.0250.00316.75
7.1.110.0180.01116.61
7.1.100.0180.01116.70
7.1.90.0140.01416.65
7.1.80.0190.01016.32
7.1.70.0240.01016.60
7.1.60.0230.00316.65
7.1.50.0290.00016.89
7.1.40.0240.00416.59
7.1.30.0260.00316.62
7.1.20.0190.00916.50
7.1.10.0220.00616.82
7.1.00.0150.01316.88
7.0.330.0170.01016.42
7.0.320.0190.00816.36
7.0.310.0140.01416.55
7.0.300.0310.00616.21
7.0.290.0210.01216.25
7.0.280.0140.01416.37
7.0.270.0180.00916.48
7.0.260.0180.00916.57
7.0.250.0140.01416.64
7.0.240.0140.01416.47
7.0.230.0210.00716.67
7.0.220.0280.00016.68
7.0.210.0210.00716.79
7.0.200.0180.00916.62
7.0.190.0330.00016.42
7.0.180.0090.00616.79
7.0.170.0110.00216.63
7.0.160.0060.00616.43
7.0.150.0200.00616.52
7.0.140.0190.00816.63
7.0.130.0170.01016.62
7.0.120.0210.00716.39
7.0.110.0240.00316.52
7.0.100.0220.00616.67
7.0.90.0240.00316.46
7.0.80.0230.00416.53
7.0.70.0170.01016.51
7.0.60.0220.00416.44
7.0.50.0230.00416.56
7.0.40.0160.01116.44
7.0.30.0190.00816.70
7.0.20.0160.01116.32
7.0.10.0230.00516.33
7.0.00.0220.01316.41
5.6.400.0180.00315.19
5.6.390.0140.00515.36
5.6.380.0170.01315.28
5.6.370.0200.00415.36
5.6.360.0200.00615.52
5.6.350.0210.00415.47
5.6.340.0250.00415.25
5.6.330.0210.00715.30
5.6.320.0220.00615.42
5.6.310.0130.01615.48
5.6.300.0250.00814.91
5.6.290.0360.00715.13
5.6.280.0120.00415.38
5.6.270.0220.00415.09
5.6.260.0230.00015.22
5.6.250.0160.00715.39
5.6.240.0260.00315.50
5.6.230.0140.01415.48
5.6.220.0180.00715.41
5.6.210.0190.00915.53
5.6.200.0210.00715.47
5.6.190.0210.00715.43
5.6.180.0240.00415.48
5.6.170.0250.00315.56
5.6.160.0220.00615.68
5.6.150.0240.00315.54
5.6.140.0340.00015.42
5.6.130.0200.01115.44
5.6.120.0250.00415.32
5.6.110.0210.00815.38
5.6.100.0170.01015.32
5.6.90.0220.00715.35
5.6.80.0200.00715.31
5.6.70.0210.00415.49
5.6.60.0180.00415.54
5.6.50.0200.00315.54
5.6.40.0240.00315.46
5.6.30.0200.01015.18
5.6.20.0240.00315.28
5.6.10.0250.00315.15
5.6.00.0220.00415.36
5.5.380.0210.00715.53
5.5.370.0280.00015.37
5.5.360.0260.00315.56
5.5.350.0250.00315.28
5.5.340.0240.00315.27
5.5.330.0180.00715.31
5.5.320.0170.01015.53
5.5.310.0250.00415.51
5.5.300.0260.00315.27
5.5.290.0310.00015.14
5.5.280.0210.00815.28
5.5.270.0290.00315.14
5.5.260.0190.00615.36
5.5.250.0200.00515.53
5.5.240.0230.00415.52
5.5.230.0220.00615.52
5.5.220.0270.00015.59
5.5.210.0250.00315.33
5.5.200.0180.00915.12
5.5.190.0190.00815.07
5.5.180.0200.00815.25
5.5.170.0200.00715.44
5.5.160.0190.00815.13
5.5.150.0240.00315.21
5.5.140.0240.00315.15
5.5.130.0230.00415.15
5.5.120.0240.00314.84
5.5.110.0210.00914.86
5.5.100.0210.00715.22
5.5.90.0160.01115.46
5.5.80.0200.00715.43
5.5.70.0200.01015.16
5.5.60.0340.00315.14
5.5.50.0170.01015.30
5.5.40.0200.00815.32
5.5.30.0170.01015.33
5.5.20.0240.00315.23
5.5.10.0200.00815.34
5.5.00.0180.00615.55
5.4.450.0140.00613.94
5.4.440.0190.00313.94
5.4.430.0180.00413.94
5.4.420.0160.00613.94
5.4.410.0180.00413.94
5.4.400.0140.00713.94
5.4.390.0150.00313.94
5.4.380.0140.00813.94
5.4.370.0180.00413.94
5.4.360.0160.00613.94
5.4.350.0230.00013.94
5.4.340.0180.00413.94
5.4.330.0150.00813.94
5.4.320.0170.00713.94
5.4.310.0180.00413.94
5.4.300.0220.00013.94
5.4.290.0230.00013.94
5.4.280.0250.00013.94
5.4.270.0150.00713.94
5.4.260.0140.00713.94
5.4.250.0180.00313.94
5.4.240.0200.00413.94
5.4.230.0240.00013.94
5.4.220.0090.01013.94
5.4.210.0180.00413.94
5.4.200.0150.00613.94
5.4.190.0180.00313.94
5.4.180.0180.00313.94
5.4.170.0140.00713.94
5.4.160.0130.01013.94
5.4.150.0180.00413.94
5.4.140.0150.00613.94
5.4.130.0160.00613.94
5.4.120.0130.00813.94
5.4.110.0120.00813.94
5.4.100.0170.00013.94
5.4.90.0140.00713.94
5.4.80.0150.00613.94
5.4.70.0140.00713.94
5.4.60.0190.00413.94
5.4.50.0210.00013.94
5.4.40.0190.00513.94
5.4.30.0180.00413.94
5.4.20.0210.00013.94
5.4.10.0180.00313.94
5.4.00.0130.01013.94
5.3.290.0150.00713.94
5.3.280.0160.00813.94
5.3.270.0200.00313.94
5.3.260.0110.01113.94
5.3.250.0130.00413.94
5.3.240.0050.00513.94
5.3.230.0070.00313.94
5.3.220.0150.00613.94
5.3.210.0190.00313.94
5.3.200.0210.00413.94
5.3.190.0150.00413.94
5.3.180.0120.00913.94
5.3.170.0190.00313.94
5.3.160.0180.00413.94
5.3.150.0150.00713.94
5.3.140.0180.00413.94
5.3.130.0140.00713.94
5.3.120.0180.00713.94
5.3.110.0160.00713.94
5.3.100.0170.00613.94
5.3.90.0090.01313.94
5.3.80.0130.00713.94
5.3.70.0260.00713.94
5.3.60.0190.00313.94
5.3.50.0150.00613.94
5.3.40.0220.00013.94
5.3.30.0160.00713.94
5.3.20.0190.00413.94
5.3.10.0120.00813.94
5.3.00.0130.00713.94
5.2.170.0140.00313.94
5.2.160.0090.00913.94
5.2.150.0040.01313.94
5.2.140.0130.00413.94
5.2.130.0100.00813.94
5.2.120.0140.00313.94
5.2.110.0170.00013.94
5.2.100.0120.00513.94
5.2.90.0110.00713.94
5.2.80.0070.01113.94
5.2.70.0170.00213.94
5.2.60.0080.00313.94
5.2.50.0080.00013.94
5.2.40.0110.00313.94
5.2.30.0140.00013.94
5.2.20.0070.00713.94
5.2.10.0090.00913.94
5.2.00.0130.00313.94
5.1.60.0120.00313.94
5.1.50.0120.00413.94
5.1.40.0080.00813.94
5.1.30.0090.00613.94
5.1.20.0130.00313.94
5.1.10.0150.00013.94
5.1.00.0120.00413.94
5.0.50.0120.00313.94
5.0.40.0090.00413.94
5.0.30.0090.00413.94
5.0.20.0070.00713.94
5.0.10.0160.00013.94
5.0.00.0130.00013.94
4.4.90.0070.00013.94
4.4.80.0080.00013.94
4.4.70.0080.00013.94
4.4.60.0080.00013.94
4.4.50.0050.00313.94
4.4.40.0000.00813.94
4.4.30.0080.00013.94
4.4.20.0050.00313.94
4.4.10.0080.00013.94
4.4.00.0060.00213.94
4.3.110.0080.00013.94
4.3.100.0000.00813.94
4.3.90.0000.00813.94
4.3.80.0080.00013.94
4.3.70.0080.00013.94
4.3.60.0070.00013.94
4.3.50.0080.00013.94
4.3.40.0080.00013.94
4.3.30.0060.00013.94
4.3.20.0060.00013.94
4.3.10.0040.00413.94
4.3.00.0030.00313.94

preferences:
32.07 ms | 403 KiB | 5 Q