3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $examples = array( 'Valid ASCII' => "a", 'Valid 2 Octet Sequence' => "\xc3\xb1", 'Invalid 2 Octet Sequence' => "\xc3\x28", 'Invalid Sequence Identifier' => "\xa0\xa1", 'Valid 3 Octet Sequence' => "\xe2\x82\xa1", 'Invalid 3 Octet Sequence (in 2nd Octet)' => "\xe2\x28\xa1", 'Invalid 3 Octet Sequence (in 3rd Octet)' => "\xe2\x82\x28", 'Valid 4 Octet Sequence' => "\xf0\x90\x8c\xbc", 'Invalid 4 Octet Sequence (in 2nd Octet)' => "\xf0\x28\x8c\xbc", 'Invalid 4 Octet Sequence (in 3rd Octet)' => "\xf0\x90\x28\xbc", 'Invalid 4 Octet Sequence (in 4th Octet)' => "\xf0\x28\x8c\x28", 'Valid 5 Octet Sequence (but not Unicode!)' => "\xf8\xa1\xa1\xa1\xa1", 'Valid 6 Octet Sequence (but not Unicode!)' => "\xfc\xa1\xa1\xa1\xa1\xa1", ); foreach ($examples as $k => $v) { echo "{$k}\n"; echo var_dump((bool)preg_match("//u", $v)); echo "\n"; }
Output for 4.4.9, 5.2.5 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Valid ASCII bool(true) Valid 2 Octet Sequence bool(true) Invalid 2 Octet Sequence bool(false) Invalid Sequence Identifier bool(false) Valid 3 Octet Sequence bool(true) Invalid 3 Octet Sequence (in 2nd Octet) bool(false) Invalid 3 Octet Sequence (in 3rd Octet) bool(false) Valid 4 Octet Sequence bool(true) Invalid 4 Octet Sequence (in 2nd Octet) bool(false) Invalid 4 Octet Sequence (in 3rd Octet) bool(false) Invalid 4 Octet Sequence (in 4th Octet) bool(false) Valid 5 Octet Sequence (but not Unicode!) bool(false) Valid 6 Octet Sequence (but not Unicode!) bool(false)
Output for 4.3.5 - 4.4.8, 5.0.0 - 5.2.4
Valid ASCII bool(true) Valid 2 Octet Sequence bool(true) Invalid 2 Octet Sequence bool(false) Invalid Sequence Identifier bool(false) Valid 3 Octet Sequence bool(true) Invalid 3 Octet Sequence (in 2nd Octet) bool(false) Invalid 3 Octet Sequence (in 3rd Octet) bool(false) Valid 4 Octet Sequence bool(true) Invalid 4 Octet Sequence (in 2nd Octet) bool(false) Invalid 4 Octet Sequence (in 3rd Octet) bool(false) Invalid 4 Octet Sequence (in 4th Octet) bool(false) Valid 5 Octet Sequence (but not Unicode!) bool(true) Valid 6 Octet Sequence (but not Unicode!) bool(true)
Output for 4.3.0 - 4.3.4
Valid ASCII bool(true) Valid 2 Octet Sequence bool(true) Invalid 2 Octet Sequence bool(true) Invalid Sequence Identifier bool(true) Valid 3 Octet Sequence bool(true) Invalid 3 Octet Sequence (in 2nd Octet) bool(true) Invalid 3 Octet Sequence (in 3rd Octet) bool(true) Valid 4 Octet Sequence bool(true) Invalid 4 Octet Sequence (in 2nd Octet) bool(true) Invalid 4 Octet Sequence (in 3rd Octet) bool(true) Invalid 4 Octet Sequence (in 4th Octet) bool(true) Valid 5 Octet Sequence (but not Unicode!) bool(true) Valid 6 Octet Sequence (but not Unicode!) bool(true)