3v4l.org

run code in 300+ PHP versions simultaneously
<?php $examples = array( 'Valid ASCII' => array("a", true), 'Valid 2 Octet Sequence' => array("\xc3\xb1", true), 'Invalid 2 Octet Sequence' => array("\xc3\x28", false), 'Invalid Sequence Identifier' => array("\xa0\xa1", false), 'Valid 3 Octet Sequence' => array("\xe2\x82\xa1", true), 'Invalid 3 Octet Sequence (in 2nd Octet)' => array("\xe2\x28\xa1", false), 'Invalid 3 Octet Sequence (in 3rd Octet)' => array("\xe2\x82\x28", false), 'Valid 4 Octet Sequence' => array("\xf0\x90\x8c\xbc", true), 'Invalid 4 Octet Sequence (in 2nd Octet)' => array("\xf0\x28\x8c\xbc", false), 'Invalid 4 Octet Sequence (in 3rd Octet)' => array("\xf0\x90\x28\xbc", false), 'Invalid 4 Octet Sequence (in 4th Octet)' => array("\xf0\x28\x8c\x28", false), 'Valid 5 Octet Sequence (but not Unicode!)' => array("\xf8\xa1\xa1\xa1\xa1", false), 'Valid 6 Octet Sequence (but not Unicode!)' => array("\xfc\xa1\xa1\xa1\xa1\xa1", false), ); function checkWithPreg($str) { return preg_match('//u', $str); } function checkWithMbstring($str) { return mb_check_encoding($str, 'UTF-8'); } function test($actual, $expected, $title) { echo $actual == $expected ? "[Success]" : "[Fail]"; echo " $title\n"; } function runTests($method) { global $examples; foreach($examples as $title => $arr) { list($str, $bool) = $arr; test($method($str), $bool, $title); } } runTests('checkWithPreg'); echo "\n"; runTests('checkWithMbstring');
Output for git.master, git.master_jit, rfc.property-hooks
[Success] Valid ASCII [Success] Valid 2 Octet Sequence [Success] Invalid 2 Octet Sequence [Success] Invalid Sequence Identifier [Success] Valid 3 Octet Sequence [Success] Invalid 3 Octet Sequence (in 2nd Octet) [Success] Invalid 3 Octet Sequence (in 3rd Octet) [Success] Valid 4 Octet Sequence [Success] Invalid 4 Octet Sequence (in 2nd Octet) [Success] Invalid 4 Octet Sequence (in 3rd Octet) [Success] Invalid 4 Octet Sequence (in 4th Octet) [Success] Valid 5 Octet Sequence (but not Unicode!) [Success] Valid 6 Octet Sequence (but not Unicode!) [Success] Valid ASCII [Success] Valid 2 Octet Sequence [Success] Invalid 2 Octet Sequence [Success] Invalid Sequence Identifier [Success] Valid 3 Octet Sequence [Success] Invalid 3 Octet Sequence (in 2nd Octet) [Success] Invalid 3 Octet Sequence (in 3rd Octet) [Success] Valid 4 Octet Sequence [Success] Invalid 4 Octet Sequence (in 2nd Octet) [Success] Invalid 4 Octet Sequence (in 3rd Octet) [Success] Invalid 4 Octet Sequence (in 4th Octet) [Success] Valid 5 Octet Sequence (but not Unicode!) [Success] Valid 6 Octet Sequence (but not Unicode!)

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:
51.3 ms | 403 KiB | 8 Q