3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = 'œ'; preg_match_all('/[^[:alnum:]]/', $str, $matches); echo "The string is read byte by byte, \nthe pattern matches the two bytes of œ separately.\n"; print_r($matches[0]); preg_match_all('/[^[:alnum:]]/u', $str, $matches); echo "\nThe string is read code point by code point encoded in utf-8,\nbut since [:alnum:] is extended,\nit contains œ, so there's no match.\n"; print_r($matches[0]); preg_match_all('/(*UCP)[^[:alnum:]]/', $str, $matches, PREG_OFFSET_CAPTURE); echo "\nThe string is read byte by byte,\nand because [:alnum:] contains œ with (*UCP),\nit fails at position 0 but succeeds on the second byte at position 1.\n"; print_r($matches[0]); preg_match_all('/(*UTF)[^[:alnum:]]/', $str, $matches); echo "\nThe string is read code point by code point,\n[:alnum:] doesn't contain œ,\nthe pattern matches at position 0 and return a code point.\n"; print_r($matches[0]);
Output for rfc.property-hooks, git.master, git.master_jit
The string is read byte by byte, the pattern matches the two bytes of œ separately. Array ( [0] => � [1] => � ) The string is read code point by code point encoded in utf-8, but since [:alnum:] is extended, it contains œ, so there's no match. Array ( ) The string is read byte by byte, and because [:alnum:] contains œ with (*UCP), it fails at position 0 but succeeds on the second byte at position 1. Array ( [0] => Array ( [0] => � [1] => 1 ) ) The string is read code point by code point, [:alnum:] doesn't contain œ, the pattern matches at position 0 and return a code point. Array ( [0] => œ )

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:
50.7 ms | 1541 KiB | 4 Q