3v4l.org

run code in 200+ 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));
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/jFQO8
function name:  (null)
number of ops:  11
compiled vars:  !0 = $foo
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   ASSIGN                                                   !0, '%F0%9F%9A%81-+Tour+%40exslagermaurice'
   5     1        NOP                                                      
  19     2        NOP                                                      
  34     3        NOP                                                      
  39     4        INIT_FCALL                                               'var_dump'
         5        INIT_FCALL                                               'utf8_html_encode'
         6        SEND_VAR                                                 !0
         7        DO_FCALL                                      0  $2      
         8        SEND_VAR                                                 $2
         9        DO_ICALL                                                 
        10      > RETURN                                                   1

Function is_ascii:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/jFQO8
function name:  is_ascii
number of ops:  9
compiled vars:  !0 = $str
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   5     0  E >   RECV                                             !0      
   7     1        INIT_FCALL                                               'preg_match'
         2        SEND_VAL                                                 '%2F%5B%5Cx80-%5CxFF%5D%2F'
         3        SEND_VAR                                                 !0
         4        DO_ICALL                                         $1      
         5        BOOL_NOT                                         ~2      $1
         6        CAST                                         13  ~3      ~2
         7      > RETURN                                                   ~3
   8     8*     > RETURN                                                   null

End of function is_ascii

Function utf8_single_chr_html_encode:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/jFQO8
function name:  utf8_single_chr_html_encode
number of ops:  8
compiled vars:  !0 = $chr
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  19     0  E >   RECV                                             !0      
  21     1        INIT_FCALL_BY_NAME                                       'utf8_ord'
         2        SEND_VAR_EX                                              !0
         3        DO_FCALL                                      0  $1      
         4        CONCAT                                           ~2      '%26%23', $1
         5        CONCAT                                           ~3      ~2, '%3B'
         6      > RETURN                                                   ~3
  22     7*     > RETURN                                                   null

End of function utf8_single_chr_html_encode

Function utf8_html_encode:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/jFQO8
function name:  utf8_html_encode
number of ops:  13
compiled vars:  !0 = $str
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  34     0  E >   RECV                                             !0      
  36     1        INIT_FCALL                                               'implode'
         2        INIT_FCALL                                               'array_map'
         3        SEND_VAL                                                 'utf8_single_chr_html_encode'
         4        INIT_FCALL_BY_NAME                                       'utf8_split'
         5        SEND_VAR_EX                                              !0
         6        DO_FCALL                                      0  $1      
         7        SEND_VAR                                                 $1
         8        DO_ICALL                                         $2      
         9        SEND_VAR                                                 $2
        10        DO_ICALL                                         $3      
        11      > RETURN                                                   $3
  37    12*     > RETURN                                                   null

End of function utf8_html_encode

Generated using Vulcan Logic Dumper, using php 7.2.0