3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php if(function_exists("json_encode")) { $table = get_html_translation_table(HTML_ENTITIES); $table = utf($table); echo json_encode(get_html_translation_table(HTML_ENTITIES)); } function is_utf($string) { return preg_match('%(?:[\xC2-\xDF][\x80-\xBF]|\xE0[\xA0-\xBF][\x80-\xBF]|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}|\xED[\x80-\x9F][\x80-\xBF]|\xF0[\x90-\xBF][\x80-\xBF]{2}|[\xF1-\xF3][\x80-\xBF]{3}|\xF4[\x80-\x8F][\x80-\xBF]{2})+%xs', $string); } function utf($yolo) { if(is_array($yolo)) { $result = array(); foreach($yolo as $yo => $lo) $result[utf($yo)] = utf($lo); } elseif(is_string($yolo) && !is_utf($yolo)) $result = utf8_encode($yolo); else $result = $yolo; return $result; }
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = 4, Position 2 = 19
Branch analysis from position: 4
Jump found. Position 1 = -2
Branch analysis from position: 19
filename:       /in/GYCVc
function name:  (null)
number of ops:  22
compiled vars:  !0 = $table
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   2     0  E >   INIT_FCALL                                               'function_exists'
         1        SEND_VAL                                                 'json_encode'
         2        DO_ICALL                                         $1      
         3      > JMPZ                                                     $1, ->19
   4     4    >   INIT_FCALL                                               'get_html_translation_table'
         5        SEND_VAL                                                 1
         6        DO_ICALL                                         $2      
         7        ASSIGN                                                   !0, $2
   5     8        INIT_FCALL_BY_NAME                                       'utf'
         9        SEND_VAR_EX                                              !0
        10        DO_FCALL                                      0  $4      
        11        ASSIGN                                                   !0, $4
   6    12        INIT_FCALL                                               'json_encode'
        13        INIT_FCALL                                               'get_html_translation_table'
        14        SEND_VAL                                                 1
        15        DO_ICALL                                         $6      
        16        SEND_VAR                                                 $6
        17        DO_ICALL                                         $7      
        18        ECHO                                                     $7
  10    19    >   NOP                                                      
  15    20        NOP                                                      
  28    21      > RETURN                                                   1

Function is_utf:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/GYCVc
function name:  is_utf
number of ops:  7
compiled vars:  !0 = $string
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  10     0  E >   RECV                                             !0      
  12     1        INIT_FCALL                                               'preg_match'
         2        SEND_VAL                                                 '%25%28%3F%3A%5B%5CxC2-%5CxDF%5D%5B%5Cx80-%5CxBF%5D%7C%5CxE0%5B%5CxA0-%5CxBF%5D%5B%5Cx80-%5CxBF%5D%7C%5B%5CxE1-%5CxEC%5CxEE%5CxEF%5D%5B%5Cx80-%5CxBF%5D%7B2%7D%7C%5CxED%5B%5Cx80-%5Cx9F%5D%5B%5Cx80-%5CxBF%5D%7C%5CxF0%5B%5Cx90-%5CxBF%5D%5B%5Cx80-%5CxBF%5D%7B2%7D%7C%5B%5CxF1-%5CxF3%5D%5B%5Cx80-%5CxBF%5D%7B3%7D%7C%5CxF4%5B%5Cx80-%5Cx8F%5D%5B%5Cx80-%5CxBF%5D%7B2%7D%29%2B%25xs'
         3        SEND_VAR                                                 !0
         4        DO_ICALL                                         $1      
         5      > RETURN                                                   $1
  13     6*     > RETURN                                                   null

End of function is_utf

Function utf:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = 3, Position 2 = 18
Branch analysis from position: 3
Jump found. Position 1 = 5, Position 2 = 16
Branch analysis from position: 5
Jump found. Position 1 = 6, Position 2 = 16
Branch analysis from position: 6
Jump found. Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 16
Jump found. Position 1 = 32
Branch analysis from position: 32
Jump found. Position 1 = -2
Branch analysis from position: 16
Branch analysis from position: 18
Jump found. Position 1 = 20, Position 2 = 25
Branch analysis from position: 20
Jump found. Position 1 = 26, Position 2 = 31
Branch analysis from position: 26
Jump found. Position 1 = 32
Branch analysis from position: 32
Branch analysis from position: 31
Jump found. Position 1 = -2
Branch analysis from position: 25
filename:       /in/GYCVc
function name:  utf
number of ops:  34
compiled vars:  !0 = $yolo, !1 = $result, !2 = $lo, !3 = $yo
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  15     0  E >   RECV                                             !0      
  17     1        TYPE_CHECK                                    7  ~4      !0
         2      > JMPZ                                                     ~4, ->18
  19     3    >   ASSIGN                                                   !1, <array>
  20     4      > FE_RESET_R                                       $6      !0, ->16
         5    > > FE_FETCH_R                                               $6, !2, ->16
         6    >   ASSIGN                                                   !3, ~7
  21     7        INIT_FCALL_BY_NAME                                       'utf'
         8        SEND_VAR_EX                                              !3
         9        DO_FCALL                                      0  $9      
        10        INIT_FCALL_BY_NAME                                       'utf'
        11        SEND_VAR_EX                                              !2
        12        DO_FCALL                                      0  $11     
        13        ASSIGN_DIM                                               !1, $9
        14        OP_DATA                                                  $11
        15      > JMP                                                      ->5
        16    >   FE_FREE                                                  $6
        17      > JMP                                                      ->32
  23    18    >   TYPE_CHECK                                    6  ~12     !0
        19      > JMPZ_EX                                          ~12     ~12, ->25
        20    >   INIT_FCALL                                               'is_utf'
        21        SEND_VAR                                                 !0
        22        DO_FCALL                                      0  $13     
        23        BOOL_NOT                                         ~14     $13
        24        BOOL                                             ~12     ~14
        25    > > JMPZ                                                     ~12, ->31
  24    26    >   INIT_FCALL                                               'utf8_encode'
        27        SEND_VAR                                                 !0
        28        DO_ICALL                                         $15     
        29        ASSIGN                                                   !1, $15
        30      > JMP                                                      ->32
  26    31    >   ASSIGN                                                   !1, !0
  27    32    > > RETURN                                                   !1
  28    33*     > RETURN                                                   null

End of function utf

Generated using Vulcan Logic Dumper, using php 7.2.0