3v4l.org

run code in 300+ PHP versions simultaneously
<?php function mb_detect_encoding2 ($string, $enc=null, $ret=null) { static $enclist = array( 'UTF-8', 'ASCII', 'ISO-8859-1', 'ISO-8859-2', 'ISO-8859-3', 'ISO-8859-4', 'ISO-8859-5', 'ISO-8859-6', 'ISO-8859-7', 'ISO-8859-8', 'ISO-8859-9', 'ISO-8859-10', 'ISO-8859-13', 'ISO-8859-14', 'ISO-8859-15', 'ISO-8859-16', 'Windows-1251', 'Windows-1252', 'Windows-1254', ); $result = false; foreach ($enclist as $item) { $sample = iconv($item, $item, $string); if (md5($sample) == md5($string)) { if ($ret === NULL) { $result = $item; } else { $result = true; } break; } } return $result; } $strings = array( 'ASCII' => 'ASCII', 'UTF-8' => "Tr\xc3\xb6t", 'Windows-1252 with ASCII' => "Tr\xf6t", 'Windows-1252 only' => "\xf6\xfd\x80", 'Windows-1252 only with an undefined character' => "\xf6\xfd\x81", ); $detect = array('ASCII', 'Windows-1252', 'UTF-8'); foreach ($strings as $name => $string) { $detected_loose = mb_detect_encoding2($string, $detect, true); $detected_strict = mb_detect_encoding2($string, $detect, false); if ($detected_loose === $detected_strict) { if ($detected_loose === false) { echo "'$name' could not be detected!\n"; } else { echo "'$name' was detected as $detected_loose\n"; } } else { echo "'$name' was " . ($detected_loose === false ? 'not detected' : "detected as $detected_loose") . ' in loose mode, but ' . ($detected_strict === false ? 'not detected' : "detected as $detected_strict") . " in strict mode\n"; } }

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.3.60.0140.00416.75
8.3.50.0050.01417.32
8.3.40.0070.01018.51
8.3.30.0000.01618.71
8.3.20.0050.00518.75
8.3.10.0030.00620.57
8.3.00.0090.00019.35
8.2.180.0120.00316.63
8.2.170.0040.01122.96
8.2.160.0090.00921.19
8.2.150.0040.00424.18
8.2.140.0060.00324.66
8.2.130.0060.00326.16
8.2.120.0000.00819.36
8.2.110.0070.00319.27
8.2.100.0060.00617.91
8.2.90.0060.00317.88
8.2.80.0050.00318.79
8.2.70.0060.00317.63
8.2.60.0030.00517.50
8.2.50.0070.00417.63
8.2.40.0060.00319.32
8.2.30.0050.00317.77
8.2.20.0080.00017.62
8.2.10.0000.00817.70
8.2.00.0000.01217.77
8.1.280.0120.00325.92
8.1.270.0080.00024.66
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0070.00422.16
8.1.230.0090.00422.68
8.1.220.0030.00518.71
8.1.210.0000.00818.77
8.1.200.0000.01317.35
8.1.190.0030.01017.23
8.1.180.0040.00418.10
8.1.170.0060.00317.62
8.1.160.0000.01018.92
8.1.150.0000.00818.73
8.1.140.0050.00317.39
8.1.130.0000.00717.76
8.1.120.0000.00817.56
8.1.110.0050.00317.51
8.1.100.0040.00417.43
8.1.90.0050.00317.41
8.1.80.0050.00317.39
8.1.70.0040.00417.45
8.1.60.0000.00917.50
8.1.50.0030.00617.39
8.1.40.0050.00317.46
8.1.30.0030.00717.69
8.1.20.0060.00317.61
8.1.10.0000.00817.55
8.1.00.0030.00617.52
8.0.300.0000.00718.77
8.0.290.0040.00416.75
8.0.280.0080.00018.16
8.0.270.0060.00318.01
8.0.260.0000.00716.85
8.0.250.0000.00817.03
8.0.240.0060.00316.93
8.0.230.0000.00717.09
8.0.220.0000.00716.87
8.0.210.0000.00816.88
8.0.200.0050.00217.01
8.0.190.0050.00517.07
8.0.180.0040.00416.90
8.0.170.0060.00316.99
8.0.160.0080.00017.02
8.0.150.0030.00616.95
8.0.140.0040.00416.98
8.0.130.0000.00613.44
8.0.120.0060.00317.16
8.0.110.0000.01017.05
8.0.100.0030.00717.01
8.0.90.0030.00617.04
8.0.80.0070.01317.11
8.0.70.0060.00317.21
8.0.60.0030.00617.01
8.0.50.0050.00517.01
8.0.30.0110.01017.33
8.0.20.0120.01217.33
8.0.10.0030.00617.15
8.0.00.0100.01417.06
7.4.330.0050.00012.92
7.4.320.0030.00316.55
7.4.300.0000.00716.63
7.4.290.0030.00316.55
7.4.280.0000.00716.50
7.4.270.0000.00716.54
7.4.260.0050.00013.34
7.4.250.0070.00316.85
7.4.240.0000.00916.82
7.4.230.0040.00416.54
7.4.220.0150.00916.57
7.4.210.0090.00916.70
7.4.200.0090.00016.77
7.4.190.0030.00616.97
7.4.160.0080.01316.75
7.4.150.0120.00916.93
7.4.140.0030.02116.72
7.4.130.0130.00916.79
7.4.120.0100.01316.79
7.4.110.0170.00316.74
7.4.100.0070.01816.69
7.4.90.0090.01216.63
7.4.80.0160.00719.39
7.4.70.0130.01216.66
7.4.60.0120.01216.78
7.4.50.0090.01116.52
7.4.40.0100.01116.62
7.4.30.0150.01116.38
7.4.20.0070.01716.27
7.4.10.0210.00716.48
7.4.00.0090.01315.99
7.3.330.0060.00013.23
7.3.320.0000.00513.32
7.3.310.0060.00316.39
7.3.300.0040.00416.61
7.3.290.0070.01416.61
7.3.280.0140.01216.60
7.3.270.0130.01016.70
7.3.260.0130.00816.68
7.3.250.0070.01516.68
7.3.240.0100.01016.52
7.3.230.0090.01716.71
7.3.210.0140.00716.70
7.3.200.0090.01116.64
7.3.190.0160.01216.64
7.3.180.0130.01016.63
7.3.170.0070.01416.69
7.3.160.0050.02016.56
7.3.150.0140.00916.54
7.3.140.0190.00916.45
7.3.130.0110.02116.43
7.3.120.0130.00915.79
7.3.110.0140.01416.61
7.3.100.0180.00816.60
7.3.90.0180.01116.57
7.3.80.0110.01416.54
7.3.70.0030.01916.47
7.3.60.0110.01116.38
7.3.50.0070.01416.32
7.3.40.0160.00516.49
7.3.30.0120.00816.57
7.3.20.0160.01216.45
7.3.10.0090.01716.57
7.3.00.0090.01216.51
7.2.330.0090.01217.03
7.2.320.0000.02116.95
7.2.310.0190.01316.88
7.2.300.0070.01516.76
7.2.290.0070.01316.95
7.2.280.0000.02416.62
7.2.270.0130.01216.65
7.2.260.0140.01416.81
7.2.250.0180.00916.64
7.2.240.0170.01316.53
7.2.230.0060.01816.64
7.2.220.0030.02316.75
7.2.210.0070.01716.73
7.2.200.0170.00816.58
7.2.190.0060.01516.51
7.2.180.0110.00916.53
7.2.170.0120.01116.45
7.2.160.0120.01616.66
7.2.150.0180.01516.54
7.2.140.0170.01016.64
7.2.130.0070.01316.83
7.2.120.0140.00916.77
7.2.110.0170.01316.63
7.2.100.0120.01116.68
7.2.90.0160.00716.88
7.2.80.0170.00516.67
7.2.70.0140.01116.85
7.2.60.0100.00916.79
7.2.50.0130.01016.80
7.2.40.0120.01016.79
7.2.30.0150.00816.76
7.2.20.0090.01616.54
7.2.10.0130.01116.76
7.2.00.0090.01317.72
7.1.330.0310.00715.85
7.1.320.0200.01215.77
7.1.310.0300.00715.80
7.1.300.0210.01015.77
7.1.290.0220.01715.86
7.1.280.0180.01715.79
7.1.270.0210.01015.76
7.1.260.0210.01515.71
7.1.250.0180.00815.77
7.1.240.0200.01015.75
7.1.230.0210.00915.80
7.1.220.0240.00715.78
7.1.210.0150.01915.86
7.1.200.0110.01215.97
7.1.190.0230.01515.77
7.1.180.0250.00715.95
7.1.170.0140.01815.82
7.1.160.0270.00715.91
7.1.150.0120.01815.73
7.1.140.0360.00315.75
7.1.130.0230.00915.82
7.1.120.0190.01915.73
7.1.110.0220.01315.75
7.1.100.0230.00817.17
7.1.90.0260.01015.66
7.1.80.0170.01415.79
7.1.70.0110.01216.59
7.1.60.0150.01617.61
7.1.50.0150.01016.53
7.1.40.0140.02115.69
7.1.30.0190.01515.91
7.1.20.0300.00415.78
7.1.10.0240.00915.83
7.1.00.0160.03919.26
7.0.330.0190.01715.53
7.0.320.0130.01715.61
7.0.310.0200.01015.47
7.0.300.0200.00815.37
7.0.290.0240.00415.46
7.0.280.0200.00815.64
7.0.270.0240.00815.26
7.0.260.0160.01415.30
7.0.250.0170.01215.46
7.0.240.0160.01215.42
7.0.230.0150.01815.55
7.0.220.0240.00715.51
7.0.210.0200.01015.52
7.0.200.0200.01015.08
7.0.190.0250.00715.59
7.0.180.0230.01415.39
7.0.170.0170.02315.64
7.0.160.0290.01015.52
7.0.150.0160.01615.47
7.0.140.0140.04218.87
7.0.130.0230.00815.44
7.0.120.0080.04418.89
7.0.110.0200.02015.35
7.0.100.0240.01415.45
7.0.90.0140.01715.57
7.0.80.0300.00715.50
7.0.70.0220.00915.23
7.0.60.0170.04517.66
7.0.50.0160.02316.88
7.0.40.0380.02517.80
7.0.30.0260.02417.95
7.0.20.0180.02817.93
7.0.10.0180.05117.88
7.0.00.0160.04117.85
5.6.400.0210.01416.08
5.6.390.0150.01816.25
5.6.380.0250.01016.21
5.6.370.0250.00416.14
5.6.360.0190.01116.22
5.6.350.0210.01415.99
5.6.340.0200.01016.19
5.6.330.0220.01116.17
5.6.320.0230.00916.31
5.6.310.0270.00716.23
5.6.300.0240.01415.96
5.6.290.0250.00916.04
5.6.280.0110.04518.76
5.6.270.0250.01116.27
5.6.260.0220.01216.36
5.6.250.0190.01515.93
5.6.240.0170.01716.23
5.6.230.0200.01716.08
5.6.220.0270.01416.02
5.6.210.0160.02418.29
5.6.200.0130.05617.22
5.6.190.0240.02918.33
5.6.180.0230.02918.40
5.6.170.0210.03118.41
5.6.160.0180.02818.49
5.6.150.0230.02418.41
5.6.140.0220.02918.26
5.6.130.0250.04218.34
5.6.120.0150.03818.32
5.6.110.0180.04718.32
5.6.100.0200.04918.25
5.6.90.0190.03018.26
5.6.80.0240.03017.86
5.6.70.0230.03617.91
5.6.60.0210.02618.10
5.6.50.0140.03318.15
5.6.40.0210.02917.97
5.6.30.0190.04818.02
5.6.20.0270.02317.95
5.6.10.0230.02917.98
5.6.00.0170.03218.07
5.5.380.0240.01015.94
5.5.370.0180.02216.15
5.5.360.0120.02416.02
5.5.350.0190.05018.39
5.5.340.0180.04617.00
5.5.330.0210.02818.40
5.5.320.0200.02918.39
5.5.310.0190.02918.21
5.5.300.0180.04018.12
5.5.290.0230.02618.26
5.5.280.0230.04118.13
5.5.270.0130.03718.14
5.5.260.0270.02318.20
5.5.250.0260.03918.09
5.5.240.0220.02717.74
5.5.230.0200.04817.90
5.5.220.0220.02917.89
5.5.210.0220.03717.74
5.5.200.0270.02817.81
5.5.190.0230.02918.00
5.5.180.0190.03017.71
5.5.170.0220.01116.24
5.5.160.0250.02517.74
5.5.150.0210.02717.74
5.5.140.0190.03117.79
5.5.130.0230.03317.89
5.5.120.0130.03717.84
5.5.110.0190.03117.97
5.5.100.0160.03017.88
5.5.90.0280.02517.72
5.5.80.0170.03217.91
5.5.70.0280.02817.72
5.5.60.0250.03417.87
5.5.50.0200.02717.85
5.5.40.0210.03017.81
5.5.30.0200.03017.79
5.5.20.0210.03117.88
5.5.10.0210.02817.77
5.5.00.0190.02917.82
5.4.450.0150.02916.02
5.4.440.0170.02916.21
5.4.430.0240.02216.15
5.4.420.0180.02316.24
5.4.410.0190.02616.05
5.4.400.0190.02415.97
5.4.390.0200.02516.00
5.4.380.0180.02615.78
5.4.370.0160.04415.78
5.4.360.0160.02615.96
5.4.350.0290.01816.05
5.4.340.0190.02515.83
5.4.330.0110.01112.56
5.4.320.0190.02515.84
5.4.310.0190.03415.79
5.4.300.0170.02515.79
5.4.290.0210.02115.89
5.4.280.0190.03315.95
5.4.270.0230.02215.91
5.4.260.0190.02315.94
5.4.250.0190.02315.90
5.4.240.0130.02915.75
5.4.230.0170.04015.93
5.4.220.0180.02515.92
5.4.210.0180.02916.05
5.4.200.0180.02615.86
5.4.190.0230.01816.09
5.4.180.0230.04015.84
5.4.170.0160.04316.01
5.4.160.0190.03615.82
5.4.150.0190.02515.91
5.4.140.0170.03914.67
5.4.130.0170.03614.60
5.4.120.0150.02214.57
5.4.110.0180.04314.70
5.4.100.0170.04214.66
5.4.90.0190.03914.63
5.4.80.0170.02514.65
5.4.70.0150.02114.64
5.4.60.0210.02714.71
5.4.50.0130.03714.66
5.4.40.0190.03814.65
5.4.30.0190.02314.62
5.4.20.0150.02514.65
5.4.10.0150.02414.69
5.4.00.0210.02114.29
5.3.290.0220.02614.24
5.3.280.0160.04214.13
5.3.270.0190.03314.02
5.3.260.0190.04114.09
5.3.250.0160.02614.02
5.3.240.0170.04513.96
5.3.230.0170.03613.97
5.3.220.0190.02314.02
5.3.210.0190.04114.03
5.3.200.0180.04013.98
5.3.190.0130.03014.02
5.3.180.0160.02814.08
5.3.170.0180.04514.02
5.3.160.0220.03014.15
5.3.150.0210.04514.12
5.3.140.0260.04414.01
5.3.130.0210.04014.04
5.3.120.0160.03614.07
5.3.110.0120.02914.00
5.3.100.0210.02613.75
5.3.90.0160.03113.94
5.3.80.0170.03213.74
5.3.70.0190.02413.70
5.3.60.0220.03213.70
5.3.50.0220.04113.68
5.3.40.0240.04313.64
5.3.30.0190.02413.85
5.3.20.0190.02813.63
5.3.10.0160.03113.56
5.3.00.0150.02613.46
5.2.170.0150.04012.59
5.2.160.0090.03112.58
5.2.150.0150.02312.58
5.2.140.0150.03512.56
5.2.130.0160.02312.63
5.2.120.0170.03612.48
5.2.110.0200.02312.57
5.2.100.0120.02312.51
5.2.90.0140.02012.51
5.2.80.0160.02312.45
5.2.70.0190.03312.54
5.2.60.0180.02012.45
5.2.50.0150.04012.47
5.2.40.0090.02612.61
5.2.30.0100.02412.45
5.2.20.0210.01312.40
5.2.10.0140.03612.38
5.2.00.0200.02812.36
5.1.60.0070.02412.35
5.1.50.0100.02112.38
5.1.40.0140.01712.38
5.1.30.0090.02112.38
5.1.20.0210.03012.38
5.1.10.0090.02212.38
5.1.00.0100.02112.38
5.0.50.0110.02512.38
5.0.40.0070.01512.38
5.0.30.0080.02312.38
5.0.20.0090.01512.38
5.0.10.0070.02812.38
5.0.00.0060.02412.38
4.4.90.0090.00812.35
4.4.80.0090.01012.35
4.4.70.0080.00912.35
4.4.60.0070.01012.35
4.4.50.0060.01312.35
4.4.40.0030.01812.38
4.4.30.0110.00512.38
4.4.20.0120.00512.38
4.4.10.0100.00712.38
4.4.00.0070.01312.38
4.3.110.0070.01012.38
4.3.100.0060.00912.38
4.3.90.0090.00712.38
4.3.80.0090.01212.38
4.3.70.0090.00612.38
4.3.60.0070.00812.38
4.3.50.0060.00812.38
4.3.40.0060.01312.38
4.3.30.0020.01012.38
4.3.20.0040.01112.38
4.3.10.0020.01412.38
4.3.00.0060.01612.38

preferences:
81.81 ms | 401 KiB | 5 Q