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' , utf8_split( $str ) ) ); } var_dump(utf8_html_encode($foo));
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught Error: Call to undefined function utf8_split() in /in/jFQO8:36 Stack trace: #0 /in/jFQO8(39): utf8_html_encode('\xF0\x9F\x9A\x81- Tour @exs...') #1 {main} thrown in /in/jFQO8 on line 36
Process exited with code 255.
Output for hhvm-3.12.0
Fatal error: Uncaught Error: Call to undefined function utf8_split() in /in/jFQO8:36 Stack trace: #0 /in/jFQO8(39): utf8_html_encode() #1 {main}
Process exited with code 255.
Output for 5.0.0 - 5.6.28, hhvm-3.10.0
Fatal error: Call to undefined function utf8_split() in /in/jFQO8 on line 36
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: utf8_split() in /in/jFQO8 on line 36
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: utf8_split() in /in/jFQO8 on line 36
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: utf8_split() in /in/jFQO8 on line 36