3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $foo = "🚁- Tour @exslagermaurice"; function is_ascii( $str ) { return ( bool ) !preg_match( '/[\x80-\xFF]/' , $str ); } /** * utf8_single_chr_html_encode( ) * * Converts a UTF-8 character to HTML Numbered Entity like &#123; * @since 1.0 * * @param string $chr The Unicode character to be encoded as numbered entity * @return string HTML numbered entity */ function utf8_single_chr_html_encode( $chr ) { return '&#' . utf8_ord( $chr ) . ';'; } /** * utf8_html_encode( ) * * Converts a UTF-8 string to a series of * HTML Numbered Entities like &#123;&#39;&#1740;... * @since 1.0 * * @param string $str The Unicode string to be encoded as numbered entities * @return string HTML numbered entities */ function utf8_html_encode( $str ) { return implode( array_map( 'utf8_single_chr_html_encode' , mb_split( $str ) ) ); } var_dump(mb_detect_encoding($foo)); var_dump(utf8_html_encode($foo));
Output for 5.2.5 - 5.6.28, 7.0.0 - 7.1.0
string(5) "UTF-8" Warning: mb_split() expects at least 2 parameters, 1 given in /in/pEQK6 on line 36 Warning: array_map(): Argument #2 should be an array in /in/pEQK6 on line 36 Warning: implode(): Argument must be an array in /in/pEQK6 on line 36 NULL
Output for hhvm-3.10.0 - 3.12.0
string(5) "UTF-8" Warning: mb_split() expects at least 2 parameters, 1 given in /in/pEQK6 on line 36 Warning: array_map(): Argument #2 should be an array or collection Warning: Invalid operand type was used: implode() expects a container as one of the arguments in /in/pEQK6 on line 36 NULL
Output for 4.3.4 - 5.2.4
string(5) "UTF-8" Warning: mb_split() expects at least 2 parameters, 1 given in /in/pEQK6 on line 36 Warning: array_map(): Argument #2 should be an array in /in/pEQK6 on line 36 Warning: implode(): Argument to implode must be an array. in /in/pEQK6 on line 36 NULL
Output for 4.3.2 - 4.3.3
string(5) "UTF-8" Fatal error: Call to undefined function: mb_split() in /in/pEQK6 on line 36
Process exited with code 255.
Output for 4.3.0 - 4.3.1
string(5) "UTF-8" Fatal error: Call to undefined function: mb_split() in /in/pEQK6 on line 36