3v4l.org

run code in 300+ PHP versions simultaneously
<?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", ); echo "++Invalid UTF-8 in pattern\n"; foreach ( $examples as $name => $str ) { echo "$name\n"; preg_match("/".$str."/u",'Testing'); } echo "++ preg_match() examples\n"; foreach ( $examples as $name => $str ) { preg_match("/\xf8\xa1\xa1\xa1\xa1/u", $str, $ar); echo "$name: "; if ( count($ar) == 0 ) { echo "Matched nothing!\n"; } else { echo "Matched {$ar[0]}\n"; } } echo "++ preg_match_all() examples\n"; foreach ( $examples as $name => $str ) { preg_match_all('/./u', $str, $ar); echo "$name: "; $num_utf8_chars = count($ar[0]); if ( $num_utf8_chars == 0 ) { echo "Matched nothing!\n"; } else { echo "Matched $num_utf8_chars character\n"; } }
Output for git.master, git.master_jit, rfc.property-hooks
++Invalid UTF-8 in pattern Valid ASCII Valid 2 Octet Sequence Invalid 2 Octet Sequence Warning: preg_match(): Compilation failed: UTF-8 error: byte 2 top bits not 0x80 at offset 0 in /in/UTvDt on line 22 Invalid Sequence Identifier Warning: preg_match(): Compilation failed: UTF-8 error: isolated byte with 0x80 bit set at offset 0 in /in/UTvDt on line 22 Valid 3 Octet Sequence Invalid 3 Octet Sequence (in 2nd Octet) Warning: preg_match(): Compilation failed: UTF-8 error: byte 2 top bits not 0x80 at offset 0 in /in/UTvDt on line 22 Invalid 3 Octet Sequence (in 3rd Octet) Warning: preg_match(): Compilation failed: UTF-8 error: byte 3 top bits not 0x80 at offset 0 in /in/UTvDt on line 22 Valid 4 Octet Sequence Invalid 4 Octet Sequence (in 2nd Octet) Warning: preg_match(): Compilation failed: UTF-8 error: byte 2 top bits not 0x80 at offset 0 in /in/UTvDt on line 22 Invalid 4 Octet Sequence (in 3rd Octet) Warning: preg_match(): Compilation failed: UTF-8 error: byte 3 top bits not 0x80 at offset 0 in /in/UTvDt on line 22 Invalid 4 Octet Sequence (in 4th Octet) Warning: preg_match(): Compilation failed: UTF-8 error: byte 2 top bits not 0x80 at offset 0 in /in/UTvDt on line 22 Valid 5 Octet Sequence (but not Unicode!) Warning: preg_match(): Compilation failed: UTF-8 error: 5-byte character is not allowed (RFC 3629) at offset 0 in /in/UTvDt on line 22 Valid 6 Octet Sequence (but not Unicode!) Warning: preg_match(): Compilation failed: UTF-8 error: 6-byte character is not allowed (RFC 3629) at offset 0 in /in/UTvDt on line 22 ++ preg_match() examples Warning: preg_match(): Compilation failed: UTF-8 error: 5-byte character is not allowed (RFC 3629) at offset 0 in /in/UTvDt on line 28 Valid ASCII: Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /in/UTvDt:31 Stack trace: #0 {main} thrown in /in/UTvDt on line 31
Process exited with code 255.

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