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 = $item; } 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.40.0160.00018.54
8.3.30.0100.01018.71
8.3.20.0000.00818.77
8.3.10.0090.00020.51
8.3.00.0060.00319.25
8.2.170.0030.01622.96
8.2.160.0070.00722.25
8.2.150.0030.00624.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0000.00719.76
8.2.110.0040.00720.93
8.2.100.0060.00617.91
8.2.90.0060.00319.59
8.2.80.0060.00317.97
8.2.70.0030.00617.93
8.2.60.0030.00619.65
8.2.50.0000.01018.10
8.2.40.0040.00420.59
8.2.30.0040.00419.34
8.2.20.0030.00617.59
8.2.10.0030.00617.66
8.2.00.0040.00817.79
8.1.270.0090.00023.99
8.1.260.0050.00326.35
8.1.250.0050.00328.09
8.1.240.0060.00321.20
8.1.230.0000.01121.03
8.1.220.0050.00317.79
8.1.210.0000.00818.77
8.1.200.0060.00617.23
8.1.190.0060.00317.23
8.1.180.0090.00018.10
8.1.170.0000.00818.64
8.1.160.0050.00222.25
8.1.150.0050.00318.66
8.1.140.0040.00417.48
8.1.130.0070.00017.80
8.1.120.0000.00817.41
8.1.110.0080.00017.47
8.1.100.0030.00617.52
8.1.90.0000.00817.53
8.1.80.0030.00717.38
8.1.70.0000.00717.38
8.1.60.0030.00517.62
8.1.50.0060.00317.50
8.1.40.0040.00417.44
8.1.30.0030.00517.58
8.1.20.0040.00417.67
8.1.10.0030.00517.46
8.1.00.0000.00817.42
8.0.300.0030.00519.98
8.0.290.0060.00316.75
8.0.280.0040.00418.35
8.0.270.0040.00417.29
8.0.260.0040.00418.69
8.0.250.0030.00317.11
8.0.240.0030.00616.96
8.0.230.0000.00717.04
8.0.220.0050.00317.00
8.0.210.0050.00217.02
8.0.200.0060.00617.11
8.0.190.0000.00816.94
8.0.180.0040.00416.89
8.0.170.0030.00717.00
8.0.160.0080.00016.98
8.0.150.0030.00617.01
8.0.140.0040.00716.94
8.0.130.0000.00513.45
8.0.120.0030.00617.02
8.0.110.0030.00617.14
8.0.100.0040.00717.18
8.0.90.0060.00317.26
8.0.80.0150.00317.06
8.0.70.0030.00617.21
8.0.60.0000.00917.15
8.0.50.0060.00317.16
8.0.30.0120.00917.46
8.0.20.0110.01117.40
8.0.10.0030.00617.12
8.0.00.0110.01216.92
7.4.330.0060.00014.83
7.4.320.0000.00616.44
7.4.300.0040.00416.46
7.4.290.0070.00016.52
7.4.280.0000.01016.48
7.4.270.0030.00516.55
7.4.260.0040.00313.25
7.4.250.0070.00316.76
7.4.240.0000.01016.76
7.4.230.0030.00616.70
7.4.220.0120.01216.68
7.4.210.0090.01216.79
7.4.200.0060.00316.59
7.4.190.0000.00916.66
7.4.160.0120.00816.75
7.4.150.0060.01517.40
7.4.140.0150.01217.30
7.4.130.0140.01416.68
7.4.120.0100.01016.73
7.4.110.0190.00316.73
7.4.100.0100.01016.82
7.4.90.0120.01916.67
7.4.80.0100.01019.39
7.4.70.0130.00916.67
7.4.60.0150.00616.54
7.4.50.0080.00716.67
7.4.40.0100.00919.52
7.4.30.0100.01316.80
7.4.20.0200.00716.67
7.4.10.0150.01016.40
7.4.00.0100.01115.98
7.3.330.0000.00613.37
7.3.320.0030.00313.40
7.3.310.0050.00516.64
7.3.300.0040.00416.45
7.3.290.0120.00616.61
7.3.280.0040.01316.58
7.3.270.0160.00317.40
7.3.260.0140.01018.24
7.3.250.0130.01616.68
7.3.240.0030.01716.66
7.3.230.0040.01816.57
7.3.210.0060.01416.69
7.3.200.0070.01316.78
7.3.190.0110.01216.69
7.3.180.0130.00916.57
7.3.170.0080.01216.54
7.3.160.0150.00516.56
7.3.150.0110.01216.55
7.3.140.0110.01216.54
7.3.130.0180.00416.77
7.3.120.0090.00915.95
7.3.110.0170.00916.66
7.3.100.0040.01516.48
7.3.90.0060.01516.66
7.3.80.0170.00316.57
7.3.70.0070.01416.60
7.3.60.0170.00816.61
7.3.50.0160.01016.52
7.3.40.0080.01416.34
7.3.30.0140.00816.54
7.3.20.0090.01216.68
7.3.10.0060.01316.68
7.3.00.0210.01416.61
7.2.330.0060.01516.68
7.2.320.0040.01616.86
7.2.310.0130.00916.69
7.2.300.0190.00516.69
7.2.290.0110.00916.86
7.2.280.0200.00716.85
7.2.270.0190.00716.78
7.2.260.0190.00416.84
7.2.250.0120.01816.78
7.2.240.0130.00816.78
7.2.230.0190.00316.94
7.2.220.0110.01416.88
7.2.210.0060.01516.75
7.2.200.0120.01016.85
7.2.190.0190.00716.79
7.2.180.0090.01516.93
7.2.170.0130.01616.72
7.2.160.0130.01216.61
7.2.150.0130.01216.75
7.2.140.0120.01116.62
7.2.130.0290.00916.93
7.2.120.0070.01316.83
7.2.110.0120.00816.92
7.2.100.0060.01316.93
7.2.90.0070.01416.92
7.2.80.0110.00816.94
7.2.70.0150.00616.96
7.2.60.0110.01017.06
7.2.50.0100.00916.98
7.2.40.0080.01117.01
7.2.30.0040.01816.96
7.2.20.0110.01116.93
7.2.10.0090.01216.76
7.2.00.0090.01017.91
7.1.330.0180.01815.96
7.1.320.0120.01815.90
7.1.310.0160.01615.68
7.1.300.0230.00715.86
7.1.290.0110.00715.98
7.1.280.0070.01515.80
7.1.270.0080.01415.99
7.1.260.0060.01615.68
7.1.250.0170.01015.80
7.1.240.0050.01315.67
7.1.230.0080.00815.87
7.1.220.0090.01615.86
7.1.210.0100.00815.94
7.1.200.0050.00815.83
7.1.190.0100.00915.93
7.1.180.0110.00915.86
7.1.170.0070.01215.76
7.1.160.0070.01415.84
7.1.150.0180.00715.86
7.1.140.0170.00515.84
7.1.130.0100.01115.88
7.1.120.0140.00915.89
7.1.110.0150.00715.84
7.1.100.0130.01216.80
7.1.90.0130.01115.98
7.1.80.0130.01515.83
7.1.70.0090.01516.35
7.1.60.0150.01017.05
7.1.50.0140.00916.25
7.1.40.0140.01215.80
7.1.30.0120.01315.93
7.1.20.0320.00815.85
7.1.10.0150.00615.97
7.1.00.0050.03518.02
7.0.330.0110.01215.45
7.0.320.0080.00915.51
7.0.310.0020.01615.57
7.0.300.0200.00515.39
7.0.290.0120.00815.58
7.0.280.0120.01315.47
7.0.270.0110.01215.56
7.0.260.0070.01215.52
7.0.250.0180.00715.32
7.0.240.0200.01115.59
7.0.230.0150.00815.62
7.0.220.0470.01315.44
7.0.210.0100.01915.50
7.0.200.0140.01115.93
7.0.190.0110.01015.47
7.0.180.0140.01115.43
7.0.170.0150.00715.55
7.0.160.0090.01515.55
7.0.150.0130.00915.45
7.0.140.0170.02917.76
7.0.130.0090.01115.51
7.0.120.0140.00415.50
7.0.110.0290.00715.48
7.0.100.0140.00715.47
7.0.90.0090.01115.26
7.0.80.0080.01115.30
7.0.70.0390.00815.11
7.0.60.0090.03516.89
7.0.50.0130.01716.36
7.0.40.0100.02115.63
7.0.30.0070.02215.59
7.0.20.0120.01715.61
7.0.10.0140.01615.67
7.0.00.0110.01915.66
5.6.400.0090.01516.36
5.6.390.0260.00816.28
5.6.380.0080.01115.41
5.6.370.0070.01415.22
5.6.360.0120.01015.48
5.6.350.0190.00815.48
5.6.340.0200.00615.42
5.6.330.0120.01115.34
5.6.320.0090.01115.26
5.6.310.0160.01115.50
5.6.300.0070.02215.23
5.6.290.0120.01115.17
5.6.280.0070.03117.17
5.6.270.0070.01515.36
5.6.260.0100.01315.33
5.6.250.0110.01315.18
5.6.240.0100.01615.22
5.6.230.0080.01415.16
5.6.220.0120.01215.30
5.6.210.0090.02117.10
5.6.200.0090.02316.34
5.6.190.0080.02516.32
5.6.180.0090.02216.33
5.6.170.0090.02016.41
5.6.160.0100.02116.21
5.6.150.0110.01816.24
5.6.140.0060.02216.22
5.6.130.0070.02516.32
5.6.120.0100.02116.23
5.6.110.0100.01616.26
5.6.100.0080.02016.20
5.6.90.0090.02016.31
5.6.80.0070.03116.20
5.6.70.0060.02316.12
5.6.60.0130.02816.07
5.6.50.0120.02115.97
5.6.40.0150.02916.08
5.6.30.0040.02916.12
5.6.20.0120.03416.04
5.6.10.0070.02315.95
5.6.00.0090.03216.04
5.5.380.0110.01113.73
5.5.370.0100.00513.35
5.5.360.0150.00713.52
5.5.350.1420.02015.95
5.5.340.0090.02215.10
5.5.330.0050.02315.04
5.5.320.0080.02115.01
5.5.310.0070.02115.19
5.5.300.0050.02215.20
5.5.290.0150.01715.16
5.5.280.0090.01915.18
5.5.270.0070.02015.06
5.5.260.0080.02215.13
5.5.250.0110.01715.00
5.5.240.0110.01814.87
5.5.230.0130.02614.89
5.5.220.0070.03514.80
5.5.210.0100.03614.83
5.5.200.0060.03514.85
5.5.190.0050.02414.99
5.5.180.0060.02214.84
5.5.170.0030.01213.60
5.5.160.0060.03114.80
5.5.150.0090.02714.74
5.5.140.0050.03514.82
5.5.130.0100.02614.69
5.5.120.0110.02914.85
5.5.110.0120.03114.81
5.5.100.0120.02614.87
5.5.90.0060.02714.96
5.5.80.0050.03614.59
5.5.70.0100.01914.86
5.5.60.0060.02314.78
5.5.50.0070.03514.72
5.5.40.0040.03214.80
5.5.30.0110.02214.74
5.5.20.0060.03714.70
5.5.10.0060.03514.79
5.5.00.0110.02814.87
5.4.450.0080.01814.46
5.4.440.0070.01914.38
5.4.430.0050.01814.24
5.4.420.0070.01814.40
5.4.410.0080.01914.49
5.4.400.0090.01514.29
5.4.390.0140.02614.21
5.4.380.0090.02514.34
5.4.370.0060.02514.29
5.4.360.0080.01614.32
5.4.350.0050.02414.45
5.4.340.0060.02514.40
5.4.330.0050.01011.87
5.4.320.0070.03114.32
5.4.310.0050.01814.22
5.4.300.0090.02014.28
5.4.290.0020.02414.34
5.4.280.0090.02814.28
5.4.270.0070.02814.38
5.4.260.0030.03514.26
5.4.250.0060.03314.36
5.4.240.0100.02214.20
5.4.230.0090.01814.21
5.4.220.0100.02814.30
5.4.210.0060.02814.32
5.4.200.0120.02414.32
5.4.190.0040.02714.20
5.4.180.0150.02514.23
5.4.170.0090.03214.17
5.4.160.0080.02114.31
5.4.150.0130.02814.27
5.4.140.0110.02813.39
5.4.130.0080.03013.45
5.4.120.0110.02113.43
5.4.110.0120.02813.48
5.4.100.0060.03313.55
5.4.90.0080.03213.41
5.4.80.0090.02213.33
5.4.70.0090.03113.44
5.4.60.0130.01213.55
5.4.50.0060.03113.34
5.4.40.0090.02813.45
5.4.30.0070.02713.44
5.4.20.0040.02213.45
5.4.10.0070.03013.49
5.4.00.0040.03213.14
5.3.290.0040.03612.97
5.3.280.0060.03212.90
5.3.270.0110.02013.00
5.3.260.0080.03512.94
5.3.250.0150.03112.96
5.3.240.0100.02112.87
5.3.230.0110.02912.89
5.3.220.0110.03312.96
5.3.210.0080.03212.94
5.3.200.0100.03212.96
5.3.190.0120.03012.96
5.3.180.0120.03113.08
5.3.170.0080.02613.03
5.3.160.0110.01712.96
5.3.150.0060.03313.05
5.3.140.0090.03113.07
5.3.130.0110.02212.92
5.3.120.0060.01812.94
5.3.110.0080.02913.01
5.3.100.0090.03012.87
5.3.90.0100.03112.87
5.3.80.0080.02612.71
5.3.70.0090.03112.72
5.3.60.0070.03412.73
5.3.50.0060.02112.71
5.3.40.0040.03612.80
5.3.30.0110.02912.71
5.3.20.0080.02512.69
5.3.10.0080.03012.55
5.3.00.0090.02412.48
5.2.170.0080.02611.27
5.2.160.0070.02011.29
5.2.150.0050.02211.29
5.2.140.0060.02511.28
5.2.130.0090.01511.28
5.2.120.0040.02311.26
5.2.110.0070.01811.24
5.2.100.0090.01711.22
5.2.90.0110.01611.21
5.2.80.0050.02911.20
5.2.70.0030.02911.20
5.2.60.0100.02311.19
5.2.50.0080.02111.26
5.2.40.0040.01811.11
5.2.30.0060.02911.11
5.2.20.0060.02611.11
5.2.10.0040.02111.08
5.2.00.0060.01911.04
5.1.60.0060.02610.77
5.1.50.0060.02610.76
5.1.40.0030.02210.75
5.1.30.0090.01510.82
5.1.20.0040.02010.88
5.1.10.0100.02610.72
5.1.00.0070.02310.81
5.0.50.0030.01710.30
5.0.40.0030.01710.30
5.0.30.0020.02310.16
5.0.20.0070.02110.15
5.0.10.0060.02110.16
5.0.00.0050.01910.22
4.4.90.0030.0149.98
4.4.80.0030.0169.98
4.4.70.0040.0129.98
4.4.60.0030.0169.98
4.4.50.0030.0119.98
4.4.40.0020.0209.98
4.4.30.0030.0119.98
4.4.20.0030.0139.98
4.4.10.0030.0099.98
4.4.00.0000.0179.98
4.3.110.0020.0169.98
4.3.100.0050.0119.98
4.3.90.0040.0109.98
4.3.80.0020.0119.98
4.3.70.0020.0119.98
4.3.60.0040.0129.98
4.3.50.0030.0149.98
4.3.40.0060.0179.98
4.3.30.0030.0149.98
4.3.20.0020.0129.98
4.3.10.0030.0119.98
4.3.00.0030.0119.98

preferences:
46.16 ms | 400 KiB | 5 Q