3v4l.org

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

Function is_ascii:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pEQK6
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        BOOL                                             ~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
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pEQK6
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
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pEQK6
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                                               'mb_split'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $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 8.0.0


preferences:
164.17 ms | 1403 KiB | 26 Q