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";
Output for git.master, git.master_jit
Internal Encoding set? 1 Internal Encoding: ISO-8859-9 Valid UTF-8? 1 Valid ISO-8859-9? 1 Convert string to ISO-8859-9 from ISO-8859-9 while internal encoding ISO-8859-9: ııİöÖğĞçÇşŞ Convert string to ISO-8859-9 with no source supplied: ııİöÖğĞçÇşŞ *** Convert string to UTF-8 from ISO-8859-9: ııİöÖğĞçÇşŞ Array ( [0] => ASCII [1] => UTF-8 ) Detect Order: 1 Encoding detected? UTF-8 Detect Order set? 1 Array ( [0] => ASCII [1] => UTF-8 [2] => ISO-8859-9 [3] => ISO-8859-15 ) Detect Order: 1 Encoding detected? ISO-8859-9 Internal Encoding set? 1 Convert string ISO-8859-9 from ISO-8859-9 while internal encoding is UTF-8: ııİöÖğĞçÇşŞ Encoding detected? ISO-8859-9 *** Convert string to UTF-8 using Detected Encoding ISO-8859-9 as source encoding: ııİöÖğĞçÇşŞ *** Convert string to UTF-8 without supplying a source encoding: ııİöÖğĞçÇşŞ *** Convert string to UTF-8 using UTF-8 as source encoding: ııİöÖğĞçÇşŞ Convert string to ISO-8859-9 from UTF-8: ��������� Convert resultant string to UTF-8 from ISO-8859-9: ııİöÖğĞçÇşŞ Convert resultant string to UTF-8 from UTF-8: ııİöÖğĞçÇşŞ
Output for rfc.property-hooks
Internal Encoding set? 1 Internal Encoding: ISO-8859-9 Valid UTF-8? 1 Valid ISO-8859-9? 1 Convert string to ISO-8859-9 from ISO-8859-9 while internal encoding ISO-8859-9: ııİöÖğĞçÇşŞ Convert string to ISO-8859-9 with no source supplied: ııİöÖğĞçÇşŞ *** Convert string to UTF-8 from ISO-8859-9: ııİöÖğĞçÇşŞ Array ( [0] => ASCII [1] => UTF-8 ) Detect Order: 1 Encoding detected? UTF-8 Detect Order set? 1 Array ( [0] => ASCII [1] => UTF-8 [2] => ISO-8859-9 [3] => ISO-8859-15 ) Detect Order: 1 Encoding detected? UTF-8 Internal Encoding set? 1 Convert string ISO-8859-9 from ISO-8859-9 while internal encoding is UTF-8: ııİöÖğĞçÇşŞ Encoding detected? UTF-8 *** Convert string to UTF-8 using Detected Encoding UTF-8 as source encoding: ııİöÖğĞçÇşŞ *** Convert string to UTF-8 without supplying a source encoding: ııİöÖğĞçÇşŞ *** Convert string to UTF-8 using UTF-8 as source encoding: ııİöÖğĞçÇşŞ Convert string to ISO-8859-9 from UTF-8: ��������� Convert resultant string to UTF-8 from ISO-8859-9: ııİöÖğĞçÇşŞ Convert resultant string to UTF-8 from UTF-8: ııİöÖğĞçÇşŞ

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
31.86 ms | 411 KiB | 5 Q