3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Php8CompatUtils { 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) == 0; } // 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; } if (is_array($a) || is_array($b)) { return static::standardArrayCompare($a, $b) < 0; } return $a > $b; } public static function lt($a, $b): bool { if (static::eq($a, $b)) { return false; } if (is_array($a) || is_array($b)) { return static::standardArrayCompare($a, $b) > 0; } return $a < $b; } public static function gte($a, $b): bool { if (is_array($a) || is_array($b)) { return static::standardArrayCompare($a, $b) >= 0; } return static::eq($a, $b) || ($a > $b); } public static function lte($a, $b): bool { if (is_array($a) || is_array($b)) { return static::standardArrayCompare($a, $b) <= 0; } 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.0300.00817.88
8.4.20.0380.00917.46
8.4.10.0360.01117.48
8.3.160.0260.01116.46
8.3.150.0380.00716.52
8.3.140.0350.00716.61
8.3.130.0300.00716.51
8.3.120.0340.00416.51
8.3.110.0260.01116.59
8.3.100.0340.00516.51
8.3.90.0330.01016.70
8.3.80.0380.00816.47
8.3.70.0350.00716.46
8.3.60.0340.00816.58
8.3.50.0330.00616.50
8.3.40.0280.00717.66
8.3.30.0250.01117.51
8.3.20.0260.00917.39
8.3.10.0260.00917.60
8.3.00.0170.00717.92
8.2.270.0300.00716.44
8.2.260.0350.00916.41
8.2.250.0320.00816.76
8.2.240.0250.01516.45
8.2.230.0280.01216.34
8.2.220.0270.00716.47
8.2.210.0280.00916.32
8.2.200.0320.00516.47
8.2.190.0330.00616.44
8.2.180.0280.01116.57
8.2.170.0330.00717.70
8.2.160.0280.00717.74
8.2.150.0320.00917.56
8.2.140.0360.00517.47
8.2.130.0320.00717.62
8.2.120.0330.00817.68
8.2.110.0310.01017.54
8.2.100.0320.00617.62
8.2.90.0300.00917.63
8.2.80.0320.00717.36
8.2.70.0340.00617.48
8.2.60.0240.00817.51
8.2.50.0310.00517.54
8.2.40.0240.00717.66
8.2.30.0280.00817.50
8.2.20.0280.00917.46
8.2.10.0280.00917.53
8.2.00.0310.00617.49
8.1.310.0300.00916.32
8.1.300.0310.00616.44
8.1.290.0350.00716.05
8.1.280.0300.00716.03
8.1.270.0540.00317.38
8.1.260.0320.01017.55
8.1.250.0220.01517.47
8.1.240.0260.00917.47
8.1.230.0260.00817.40
8.1.220.0210.01317.25
8.1.210.0240.01417.41
8.1.200.0300.00416.99
8.1.190.0250.01017.26
8.1.180.0330.00417.16
8.1.170.0270.00717.25
8.1.160.0320.00617.31
8.1.150.0140.00517.29
8.1.140.0340.00317.19
8.1.130.0340.00617.38
8.1.120.0330.01017.28
8.1.110.0320.00617.38
8.1.100.0250.00017.21
8.1.90.0240.01017.39
8.1.80.0290.00917.57
8.1.70.0250.01217.32
8.1.60.0180.01217.61
8.1.50.0270.00817.29
8.1.40.0250.00917.27
8.1.30.0320.00317.25
8.1.20.0250.00917.76
8.1.10.0230.00817.57
8.1.00.0180.01817.31
8.0.300.0320.00416.33
8.0.290.0390.00316.91
8.0.280.0340.00316.73
8.0.270.0290.00616.46
8.0.260.0320.00416.50
8.0.250.0320.00416.92
8.0.240.0330.00716.64
8.0.230.0370.00016.63
8.0.220.0280.00716.60
8.0.210.0220.00916.79
8.0.200.0290.00716.52
8.0.190.0250.01016.63
8.0.180.0300.00516.60
8.0.170.0240.01016.63
8.0.160.0350.00016.45
8.0.150.0350.00016.66
8.0.140.0270.00816.61
8.0.130.0290.00616.70
8.0.120.0270.00916.72
8.0.110.0330.00816.69
8.0.100.0300.00916.64
8.0.90.0350.00016.72
8.0.80.0270.00816.54
8.0.70.0260.01016.72
8.0.60.0170.02416.41
8.0.50.0300.00316.37
8.0.30.0210.01416.51
8.0.20.0260.00916.81
8.0.10.0250.00916.67
8.0.00.0350.00016.77
7.4.330.0310.00316.36
7.4.320.0310.00716.16
7.4.300.0250.00316.26
7.4.290.0260.00716.24
7.4.280.0280.00416.36
7.4.270.0290.00316.25
7.4.260.0250.00616.18
7.4.250.0190.01316.21
7.4.240.0210.00716.18
7.4.230.0260.00716.43
7.4.220.0260.00716.16
7.4.210.0320.00016.30
7.4.200.0260.00616.18
7.4.190.0260.00616.33
7.4.180.0260.00716.17
7.4.160.0190.01316.56
7.4.150.0230.01016.25
7.4.140.0130.00816.09
7.4.130.0100.00516.13
7.4.120.0200.00616.16
7.4.110.0270.00316.23
7.4.100.0360.00416.24
7.4.90.0250.00816.20
7.4.80.0220.01016.10
7.4.70.0290.00316.06
7.4.60.0260.00616.14
7.4.50.0230.00916.11
7.4.40.0220.00916.25
7.4.30.0170.00316.11
7.4.20.0230.01016.29
7.4.10.0190.00716.13
7.4.00.0330.00016.09
7.3.330.0270.00516.12
7.3.320.0250.00716.15
7.3.310.0270.00916.24
7.3.300.0380.00715.90
7.3.290.0240.00916.35
7.3.280.0210.01315.91
7.3.270.0270.00816.30
7.3.260.0250.00615.86
7.3.250.0320.00016.18
7.3.240.0230.00915.97
7.3.230.0210.01016.07
7.3.220.0300.00416.17
7.3.210.0210.01216.16
7.3.200.0150.01816.09
7.3.190.0230.01016.07
7.3.180.0270.00616.02
7.3.170.0330.00016.11
7.3.160.0320.00015.91
7.3.150.0120.02016.06
7.3.140.0240.00915.87
7.3.130.0220.01116.08
7.3.120.0250.00616.14
7.3.110.0230.01515.91
7.3.100.0240.00516.18
7.3.90.0170.01016.32
7.3.80.0280.00316.14
7.3.70.0220.01016.34
7.3.60.0260.00616.45
7.3.50.0320.00016.30
7.3.40.0200.01216.38
7.3.30.0220.00916.20
7.3.20.0220.01116.47
7.3.10.0230.01216.25
7.3.00.0300.00316.11
7.2.340.0290.00416.00
7.2.330.0240.01016.14
7.2.320.0240.01616.30
7.2.310.0270.00816.02
7.2.300.0280.00516.21
7.2.290.0280.00416.13
7.2.280.0230.00916.38
7.2.270.0280.00716.08
7.2.260.0280.00716.32
7.2.250.0320.00016.14
7.2.240.0280.00416.32
7.2.230.0290.00316.11
7.2.220.0240.00816.38
7.2.210.0200.00916.14
7.2.200.0190.00616.38
7.2.190.0190.01116.45
7.2.180.0200.01216.32
7.2.170.0180.01416.32
7.2.160.0280.00416.43
7.2.150.0310.00416.25
7.2.140.0260.00816.17
7.2.130.0310.00316.55
7.2.120.0330.00016.43
7.2.110.0350.00716.30
7.2.100.0270.00416.63
7.2.90.0210.00916.06
7.2.80.0260.01016.49
7.2.70.0340.00616.21
7.2.60.0270.00516.18
7.2.50.0220.00916.61
7.2.40.0270.00416.59
7.2.30.0180.00416.42
7.2.20.0150.00016.73
7.2.10.0230.00316.53
7.2.00.0220.01216.64
7.1.330.0250.00715.62
7.1.320.0280.00615.62
7.1.310.0260.00615.62
7.1.300.0250.00715.62
7.1.290.0280.00315.62
7.1.280.0180.01215.62
7.1.270.0240.00715.62
7.1.260.0160.01615.62
7.1.250.0140.01715.62
7.1.240.0090.00915.62
7.1.230.0080.00615.62
7.1.220.0210.00615.62
7.1.210.0140.00015.62
7.1.200.0140.00915.62
7.1.190.0260.00315.62
7.1.180.0320.00315.62
7.1.170.0240.00615.62
7.1.160.0270.00315.62
7.1.150.0240.00615.62
7.1.140.0280.00315.62
7.1.130.0280.00315.62
7.1.120.0310.00015.62
7.1.110.0230.01015.62
7.1.100.0200.00015.62
7.1.90.0680.01015.62
7.1.80.0130.00315.62
7.1.70.0220.00415.62
7.1.60.0240.00715.62
7.1.50.0310.00015.62
7.1.40.0270.00615.62
7.1.30.0210.01115.62
7.1.20.0260.00915.62
7.1.10.0140.00815.62
7.1.00.0240.00615.62
7.0.330.0260.00315.62
7.0.320.0270.00315.62
7.0.310.0170.01715.62
7.0.300.0230.00815.62
7.0.290.0260.01015.62
7.0.280.0280.01215.62
7.0.270.0160.01215.62
7.0.260.0300.00015.62
7.0.250.0280.00015.62
7.0.240.0240.00015.62
7.0.230.0220.00415.62
7.0.220.0170.01115.62
7.0.210.0660.00715.62
7.0.200.0080.00515.62
7.0.190.0180.00615.62
7.0.180.0250.00615.62
7.0.170.0160.01515.62
7.0.160.0170.01315.62
7.0.150.0260.00315.62
7.0.140.0190.01215.62
7.0.130.0130.01615.62
7.0.120.0190.01315.62
7.0.110.0260.00015.62
7.0.100.0260.00015.62
7.0.90.0280.00815.62
7.0.80.0300.00015.62
7.0.70.0240.00615.62
7.0.60.0230.00815.62
7.0.50.0230.01015.62
7.0.40.0230.00815.62
7.0.30.0220.00715.62
7.0.20.0180.01115.62
7.0.10.0200.01015.62
7.0.00.0210.00915.62
5.6.400.0180.01415.62
5.6.390.0170.00815.62
5.6.380.0190.00615.62
5.6.370.0160.00715.62
5.6.360.0210.00815.62
5.6.350.0190.00915.62
5.6.340.0210.00715.62
5.6.330.0280.00015.62
5.6.320.0280.00015.62
5.6.310.0180.00615.62
5.6.300.0240.00315.62
5.6.290.0230.00615.62
5.6.280.0260.01015.62
5.6.270.0240.00415.62
5.6.260.0150.00915.62
5.6.250.0210.00715.62
5.6.240.0180.01115.62
5.6.230.0200.00915.62
5.6.220.0200.00615.62
5.6.210.0240.00315.62
5.6.200.0280.00315.62
5.6.190.0260.00315.62
5.6.180.0270.00315.62
5.6.170.0220.00315.62
5.6.160.0200.00915.62
5.6.150.0230.00615.62
5.6.140.0220.00615.62
5.6.130.0200.00615.65
5.6.120.0270.00015.62
5.6.110.0260.00315.62
5.6.100.0220.00615.62
5.6.90.0110.00715.62
5.6.80.0130.00015.62
5.6.70.0170.00315.62
5.6.60.0170.00815.62
5.6.50.0190.00615.62
5.6.40.0380.00015.62
5.6.30.0090.01615.62
5.6.20.0210.00815.62
5.6.10.0200.00815.62
5.6.00.0220.00615.62
5.5.380.0250.00315.62
5.5.370.0220.00615.62
5.5.360.0200.00815.62
5.5.350.0250.00415.62
5.5.340.0220.00615.62
5.5.330.0260.00315.62
5.5.320.0280.00015.62
5.5.310.0220.00615.62
5.5.300.0230.00515.62
5.5.290.0180.01015.62
5.5.280.0090.00615.62
5.5.270.0270.00615.62
5.5.260.0200.00815.62
5.5.250.0220.00615.62
5.5.240.0340.00015.62
5.5.230.0110.00615.62
5.5.220.0180.00015.62
5.5.210.0060.00615.62
5.5.200.0060.00915.62
5.5.190.0260.00015.62
5.5.180.0220.00715.62
5.5.170.0100.00315.62
5.5.160.0240.00015.62
5.5.150.0270.00015.62
5.5.140.0160.01215.62
5.5.130.0150.00615.62
5.5.120.0070.00515.62
5.5.110.0140.00315.62
5.5.100.0040.00815.62
5.5.90.0100.00215.62
5.5.80.0180.00715.62
5.5.70.0210.00315.62
5.5.60.0180.00415.62
5.5.50.0250.00415.62
5.5.40.0250.00615.62
5.5.30.0260.00315.62
5.5.20.0200.00715.62
5.5.10.0180.00915.62
5.5.00.0160.01315.62
5.4.450.0180.00415.62
5.4.440.0180.00815.62
5.4.430.0180.00415.62
5.4.420.0120.00915.62
5.4.410.0180.00415.62
5.4.400.0180.00415.62
5.4.390.0190.00015.62
5.4.380.0150.00615.62
5.4.370.0140.00715.62
5.4.360.0160.00515.62
5.4.350.0250.00315.62
5.4.340.0130.00015.62
5.4.330.0150.00715.62
5.4.320.0190.00315.62
5.4.310.0130.00915.62
5.4.300.0210.00015.62
5.4.290.0150.00815.62
5.4.280.0150.00715.62
5.4.270.0180.00415.62
5.4.260.0220.00815.62
5.4.250.0180.00415.62
5.4.240.0140.00815.62
5.4.230.0120.00915.62
5.4.220.0200.00015.62
5.4.210.0190.00315.62
5.4.200.0230.00015.62
5.4.190.0140.00315.62
5.4.180.0160.00015.62
5.4.170.0180.00315.62
5.4.160.0140.00715.62
5.4.150.0180.00415.62
5.4.140.0140.00415.62
5.4.130.0180.00415.62
5.4.120.0180.00315.62
5.4.110.0100.00715.62
5.4.100.0160.00415.62
5.4.90.0100.01015.62
5.4.80.0200.00015.62
5.4.70.0100.00715.62
5.4.60.0140.00715.62
5.4.50.0210.00015.62
5.4.40.0210.00015.62
5.4.30.0180.00415.62
5.4.20.0220.00315.62
5.4.10.0140.00315.62
5.4.00.0140.00715.62
5.3.290.0150.00715.62
5.3.280.0140.00715.62
5.3.270.0140.00415.62
5.3.260.0190.00315.62
5.3.250.0150.00715.62
5.3.240.0190.00515.62
5.3.230.0130.00915.62
5.3.220.0140.00715.62
5.3.210.0150.00815.62
5.3.200.0140.01015.62
5.3.190.0160.00615.62
5.3.180.0210.00315.62
5.3.170.0170.00615.62
5.3.160.0150.00715.62
5.3.150.0160.00515.62
5.3.140.0180.00415.62
5.3.130.0170.00415.62
5.3.120.0180.00415.62
5.3.110.0150.00615.62
5.3.100.0190.00015.62
5.3.90.0170.00315.62
5.3.80.0170.00315.62
5.3.70.0150.00615.62
5.3.60.0230.00015.62
5.3.50.0240.00215.62
5.3.40.0200.00315.62
5.3.30.0200.00415.62
5.3.20.0110.00815.62
5.3.10.0120.00615.62
5.3.00.0120.00415.62
5.2.170.0090.00915.62
5.2.160.0090.00915.62
5.2.150.0090.00915.62
5.2.140.0140.00315.62
5.2.130.0150.00315.62
5.2.120.0130.00515.62
5.2.110.0180.00015.62
5.2.100.0100.00715.62
5.2.90.0140.00415.62
5.2.80.0180.00015.62
5.2.70.0110.00715.62
5.2.60.0120.00515.62
5.2.50.0090.00915.62
5.2.40.0110.00715.62
5.2.30.0150.00415.62
5.2.20.0140.00315.62
5.2.10.0130.00415.62
5.2.00.0100.00715.62
5.1.60.0130.00315.62
5.1.50.0080.00815.62
5.1.40.0160.00015.62
5.1.30.0160.00015.62
5.1.20.0120.00515.62
5.1.10.0120.00315.62
5.1.00.0070.00815.62
5.0.50.0070.00715.62
5.0.40.0130.00015.62
5.0.30.0100.00315.62
5.0.20.0140.00015.62
5.0.10.0090.00415.62
5.0.00.0110.00315.62
4.4.90.0080.00015.62
4.4.80.0080.00015.62
4.4.70.0080.00015.62
4.4.60.0080.00015.62
4.4.50.0080.00015.62
4.4.40.0080.00015.62
4.4.30.0070.00215.62
4.4.20.0090.00015.62
4.4.10.0070.00215.62
4.4.00.0000.00915.62
4.3.110.0070.00015.62
4.3.100.0070.00015.62
4.3.90.0050.00315.62
4.3.80.0050.00315.62
4.3.70.0070.00015.62
4.3.60.0060.00215.62
4.3.50.0000.00815.62
4.3.40.0050.00315.62
4.3.30.0070.00015.62
4.3.20.0040.00415.62
4.3.10.0000.00615.62
4.3.00.0000.00615.62

preferences:
69.77 ms | 403 KiB | 5 Q