3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php echo mb_detect_encoding('garcía'); print "\n"; echo mb_detect_encoding('García'); print "\n"; echo is_utf8('garcía'); print "\n"; echo is_utf8('García'); print "\n"; echo is_utf82('garcía'); print "\n"; echo is_utf82('García'); print "\n"; echo is_utf83('garcía'); print "\n"; echo is_utf83('García'); function is_utf8($str) { return (bool) preg_match('//u', $str); } function is_utf82($str) { return (bool) preg_match('!!u', $str); } function is_utf83($str) { return ! (false === mb_detect_encoding($string, 'UTF-8', true)); }
based on uYWen
Output for 5.0.4 - 7.2.6
UTF-8 UTF-8 1 1 1 1 Notice: Undefined variable: string in /in/ePkCf on line 30 1 Notice: Undefined variable: string in /in/ePkCf on line 30 1
Output for 4.3.3 - 5.0.3
UTF-8 UTF-8 1 1 1 1 Notice: Undefined variable: string in /in/ePkCf on line 30 1 Notice: Undefined variable: string in /in/ePkCf on line 30 1
Output for 4.3.0 - 4.3.2
UTF-8 UTF-8 1 1 1 1 Notice: Undefined variable: string in /in/ePkCf on line 30 Warning: Wrong parameter count for mb_detect_encoding() in /in/ePkCf on line 30 1 Notice: Undefined variable: string in /in/ePkCf on line 30 Warning: Wrong parameter count for mb_detect_encoding() in /in/ePkCf on line 30 1