3v4l.org

run code in 300+ PHP versions simultaneously
<?php $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_encoding($string, $detect, true); $detected_strict = mb_detect_encoding($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"; } }
Output for git.master, git.master_jit
'ASCII' was detected as ASCII 'UTF-8' was detected as UTF-8 'Windows-1252 with ASCII' was detected as Windows-1252 'Windows-1252 only' was detected as Windows-1252 'Windows-1252 only with an undefined character' was not detected in loose mode, but detected as Windows-1252 in strict mode
Output for rfc.property-hooks
'ASCII' was detected as ASCII 'UTF-8' was detected as UTF-8 'Windows-1252 with ASCII' was detected as Windows-1252 'Windows-1252 only' was detected as Windows-1252 'Windows-1252 only with an undefined character' was detected as Windows-1252

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:
42.78 ms | 401 KiB | 8 Q