3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Set internal encoding to ISO-8859-9 and assign string an initial value of Turkish characters $t = mb_internal_encoding('ISO-8859-9'); echo "Internal Encoding set? ".$t."\n"; $s = 'ııİöÖğĞçÇşŞ'; $t = mb_internal_encoding(); echo "Internal Encoding: ".$t."\n"; // Check if the string is valid UTF-8 $t = mb_check_encoding($s, 'UTF-8'); echo "Valid UTF-8? ".$t."\n"; // Check if the string is valid ISO-8859-1 $t = mb_check_encoding($s, 'ISO-8859-9'); echo "Valid ISO-8859-9? ".$t."\n"; //Convert string from ISO-8859-9 to ISO-8859-9 while internal encoding is ISO-8859-9 $e = mb_convert_encoding($s, 'ISO-8859-9', 'ISO-8859-9'); echo "Convert string to ISO-8859-9 from ISO-8859-9 while internal encoding ISO-8859-9: ".$e."\n"; //Convert string from ISO-8859-9 to ISO-8859-9 while internal encoding is ISO-8859-9 $i = mb_convert_encoding($s, 'ISO-8859-9'); echo "Convert string to ISO-8859-9 with no source supplied: ".$e."\n"; //Convert string to UTF-8 - if using the detected encoding it will fail $e = mb_convert_encoding($i, 'UTF-8', 'ISO-8859-9'); echo "*** Convert string to UTF-8 from ISO-8859-9: ".$e."\n"; //Display the encoding options available for detection $t = mb_detect_order(); echo "Detect Order: ".print_r($t)."\n"; //Detect encoding of string without influencing the encoding options $t = mb_detect_encoding($s); echo "Encoding detected? ".$t."\n"; //Set a preferred order of matching for detection $t = mb_detect_order('ASCII,UTF-8,ISO-8859-9,ISO-8859-15'); echo "Detect Order set? ".$t."\n"; //Display the encoding options available for detection $t = mb_detect_order(); echo "Detect Order: ".print_r($t)."\n"; //Detect encoding of string after setting the preferred order of detection $t = mb_detect_encoding($s); echo "Encoding detected? ".$t."\n"; //Set internal encoding to UTF-8 $t = mb_internal_encoding('UTF-8'); echo "Internal Encoding set? ".$t."\n"; //Convert string from ISO-8859-9 to ISO-8859-9 while internal encoding is UTF-8 $e = mb_convert_encoding($s, 'ISO-8859-9', 'ISO-8859-9'); echo "Convert string ISO-8859-9 from ISO-8859-9 while internal encoding is UTF-8: ".$e."\n"; //Detect encoding of string $t = mb_detect_encoding($s); echo "Encoding detected? ".$t."\n"; //Convert string to UTF-8 - if using the detected encoding it will fail $e = mb_convert_encoding($s, 'UTF-8', $t); echo "*** Convert string to UTF-8 using Detected Encoding $t as source encoding: ".$e."\n"; //Convert string to UTF-8 - using no source encoding works $e = mb_convert_encoding($s, 'UTF-8'); echo "*** Convert string to UTF-8 without supplying a source encoding: ".$e."\n"; //Convert string to UTF-8 - if using UTF-8 as source $e = mb_convert_encoding($s, 'UTF-8', 'UTF-8'); echo "*** Convert string to UTF-8 using UTF-8 as source encoding: ".$e."\n"; //Even though string is initialised and detected as ISO-8859-9 - it seems it is being treated //internally as though it is actually UTF-8. //Converting to ISO-8859-9 from UTF-8 works - with some characters undisplayable $e = mb_convert_encoding($s, 'ISO-8859-9', 'UTF-8'); echo "Convert string to ISO-8859-9 from UTF-8: ".$e."\n"; //Converting to this string back to UTF-8 from ISO-8859-9 works $e = mb_convert_encoding($e, 'UTF-8', 'ISO-8859-9'); echo "Convert resultant string to UTF-8 from ISO-8859-9: ".$e."\n"; //Converting to this string back to UTF-8 from UTF-8 works $e = mb_convert_encoding($e, 'UTF-8', 'UTF-8'); echo "Convert resultant string to UTF-8 from UTF-8: ".$e."\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.5.00.0090.01221.71
8.4.150.0020.00014.05
8.4.140.0100.01017.51
8.4.130.0120.00917.75
8.4.120.0050.00420.63
8.4.110.0110.00922.24
8.4.100.0180.00717.65
8.4.90.0050.00419.46
8.4.80.0100.01022.18
8.4.70.0070.00917.73
8.4.60.0170.00418.73
8.4.50.0130.00817.66
8.4.40.0060.01317.85
8.4.30.0090.01320.68
8.4.20.0160.00319.79
8.4.10.0030.01622.11
8.3.280.0090.01118.47
8.3.270.0110.00916.58
8.3.260.0150.00516.71
8.3.250.0050.00318.80
8.3.240.0030.00516.72
8.3.230.0140.00516.76
8.3.220.0130.00817.41
8.3.210.0070.01216.48
8.3.200.0050.00418.40
8.3.190.0100.00919.22
8.3.180.0100.01018.32
8.3.170.0200.00018.87
8.3.160.0110.00716.76
8.3.150.0070.01118.22
8.3.140.0120.00316.46
8.3.130.0060.00318.54
8.3.120.0060.00320.55
8.3.110.0070.00318.38
8.3.100.0060.00318.46
8.3.90.0040.00426.77
8.3.80.0040.00716.88
8.3.70.0090.00916.61
8.3.60.0070.01116.63
8.3.50.0030.01720.30
8.3.40.0100.01020.25
8.3.30.0110.00418.66
8.3.20.0020.00524.18
8.3.10.0050.00324.66
8.3.00.0000.00726.16
8.2.290.0040.00420.34
8.2.280.0080.00818.46
8.2.270.0080.00019.14
8.2.260.0050.00216.72
8.2.250.0050.00318.65
8.2.240.0130.00616.79
8.2.230.0000.00820.94
8.2.220.0070.00324.06
8.2.210.0040.00426.77
8.2.200.0090.00018.54
8.2.190.0140.00716.75
8.2.180.0070.01025.92
8.2.170.0150.00619.20
8.2.160.0070.00722.96
8.2.150.0070.00325.66
8.2.140.0040.00424.66
8.2.130.0090.00026.16
8.2.120.0070.00026.16
8.2.110.0100.00019.57
8.2.100.0060.00618.03
8.2.90.0040.00717.88
8.2.80.0030.00619.03
8.2.70.0080.00018.30
8.2.60.0040.00418.11
8.2.50.0080.00018.10
8.2.40.0030.00619.47
8.2.30.0040.00419.40
8.2.20.0040.00419.42
8.2.10.0030.00618.48
8.2.00.0050.00319.64
8.1.330.0050.00518.46
8.1.320.0120.00816.21
8.1.310.0000.01418.69
8.1.300.0040.01218.23
8.1.290.0040.00430.84
8.1.280.0070.00725.92
8.1.270.0040.00424.66
8.1.260.0040.00426.35
8.1.250.0050.00328.09
8.1.240.0070.00319.34
8.1.230.0120.00017.84
8.1.220.0000.00817.77
8.1.210.0060.00318.77
8.1.200.0070.00417.48
8.1.190.0040.00417.60
8.1.180.0060.00318.10
8.1.170.0080.00018.87
8.1.160.0040.00419.18
8.1.150.0000.00818.87
8.1.140.0050.00217.59
8.1.130.0000.00719.18
8.1.120.0000.00817.59
8.1.110.0020.00617.67
8.1.100.0070.00217.54
8.1.90.0090.00717.52
8.1.80.0040.01017.53
8.1.70.0090.00717.36
8.1.60.0110.00817.67
8.1.50.0140.00317.54
8.1.40.0100.00817.35
8.1.30.0150.00317.67
8.1.20.0150.00317.65
8.1.10.0110.00717.45
8.1.00.0130.00517.52
8.0.300.0000.00818.77
8.0.290.0000.00817.00
8.0.280.0030.00518.56
8.0.270.0030.00318.09
8.0.260.0030.00318.54
8.0.250.0000.00717.14
8.0.240.0110.00016.83
8.0.230.0040.00616.83
8.0.220.0090.00516.89
8.0.210.0030.01016.81
8.0.200.0110.00516.78
8.0.190.0090.00717.01
8.0.180.0060.00916.74
8.0.170.0150.00016.88
8.0.160.0080.00616.82
8.0.150.0090.00516.72
8.0.140.0080.00716.87
8.0.130.0090.00616.85
8.0.120.0100.00516.81
8.0.110.0140.00216.76
8.0.100.0140.00216.65
8.0.90.0150.00116.68
8.0.80.0120.00216.83
8.0.70.0120.00316.74
8.0.60.0110.00316.79
8.0.50.0120.00316.86
8.0.30.0040.01016.97
8.0.20.0110.00416.94
8.0.10.0070.00816.81
7.4.330.0000.00515.55
7.4.320.0020.00916.55
7.4.300.0100.00616.72
7.4.290.0070.00716.51
7.4.280.0140.00316.54
7.4.270.0130.00216.50
7.4.260.0120.00216.38
7.4.250.0100.00316.32
7.4.240.0070.00716.61
7.4.230.0120.00116.44
7.4.220.0100.00416.45
7.4.210.0110.00316.35
7.4.200.0090.00516.46
7.4.190.0080.00716.65
7.4.180.0100.00316.53
7.4.160.0090.00616.44
7.4.150.0140.00016.44
7.4.140.0100.00516.47
7.4.130.0140.00016.35
7.4.120.0110.00216.43
7.4.110.0070.00716.46
7.4.100.0060.00716.50
7.4.90.0090.00516.46
7.4.80.0100.00316.50
7.4.70.0060.00616.44
7.4.60.0080.00616.43
7.4.50.0090.00616.30
7.4.40.0100.00316.43
7.4.30.0080.00516.40
7.4.20.0070.00816.28
7.4.10.0090.00516.33
7.4.00.0090.00316.49

preferences:
39.81 ms | 403 KiB | 5 Q