3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function dostuff() { echo "mb_check_encoding:\n"; if ( function_exists( 'mb_check_encoding' ) ) { echo ' Surrogate: '; var_dump( mb_check_encoding( "\xED\xA0\x81\xED\xB0\x80", 'UTF-8' ) ); echo ' U+110000 : '; var_dump( mb_check_encoding( "\xF4\x90\x80\x80", 'UTF-8' ) ); echo ' U+FFFF : '; var_dump( mb_check_encoding( "\xEF\xBF\xBF", 'UTF-8' ) ); } else { echo " absent\n"; } echo "preg_match:\n"; if ( function_exists( 'preg_match' ) ) { echo ' Surrogate: '; var_dump(preg_match( '//u', "\xED\xA0\x81\xED\xB0\x80" ) ); echo ' U+110000 : '; var_dump(preg_match( '//u', "\xF4\x90\x80\x80" )); echo ' U+FFFF : '; var_dump(preg_match( '//u', "\xEF\xBF\xBF" )); } else { echo " absent\n"; } } dostuff();
Output for 5.4.0 - 5.4.13, 5.4.41 - 5.4.45, 5.5.10 - 5.6.28, hhvm-3.10.0 - 3.13.2, 7.0.0 - 7.1.0
mb_check_encoding: Surrogate: bool(false) U+110000 : bool(false) U+FFFF : bool(true) preg_match: Surrogate: bool(false) U+110000 : bool(false) U+FFFF : int(1)
Output for 5.4.14 - 5.4.40, 5.5.0 - 5.5.9
mb_check_encoding: Surrogate: bool(false) U+110000 : bool(false) U+FFFF : bool(true) preg_match: Surrogate: bool(false) U+110000 : bool(false) U+FFFF : bool(false)
Output for 5.3.24 - 5.3.29
mb_check_encoding: Surrogate: bool(false) U+110000 : bool(true) U+FFFF : bool(true) preg_match: Surrogate: bool(false) U+110000 : bool(false) U+FFFF : bool(false)
Output for 5.3.4 - 5.3.23
mb_check_encoding: Surrogate: bool(false) U+110000 : bool(true) U+FFFF : bool(true) preg_match: Surrogate: bool(false) U+110000 : bool(false) U+FFFF : int(1)
Output for 5.3.0 - 5.3.3
mb_check_encoding: Surrogate: bool(false) U+110000 : bool(true) U+FFFF : bool(true) preg_match: Surrogate: int(0) U+110000 : int(0) U+FFFF : int(1)
Output for 4.4.9, 5.2.5 - 5.2.17
mb_check_encoding: Surrogate: bool(true) U+110000 : bool(true) U+FFFF : bool(true) preg_match: Surrogate: int(0) U+110000 : int(0) U+FFFF : int(1)
Output for 4.4.3 - 4.4.8, 5.1.3 - 5.2.4
mb_check_encoding: Surrogate: bool(true) U+110000 : bool(true) U+FFFF : bool(true) preg_match: Surrogate: int(1) U+110000 : int(1) U+FFFF : int(1)
Output for 4.3.0 - 4.4.2, 5.0.0 - 5.1.2
mb_check_encoding: absent preg_match: Surrogate: int(1) U+110000 : int(1) U+FFFF : int(1)