3v4l.org

run code in 300+ PHP versions simultaneously
<?php function hex_dump($data, $newline="\n") { static $from = ''; static $to = ''; static $width = 16; # number of bytes per line static $pad = '.'; # padding for non-visible characters if ($from==='') { for ($i=0; $i<=0xFF; $i++) { $from .= chr($i); $to .= ($i >= 0x20 && $i <= 0x7E) ? chr($i) : $pad; } } $hex = str_split(bin2hex($data), $width*2); $chars = str_split(strtr($data, $from, $to), $width); $offset = 0; foreach ($hex as $i => $line) { echo sprintf('%6X',$offset).' : '.implode(' ', str_split($line,2)) . ' [' . $chars[$i] . ']' . $newline; $offset += $width; } } $str = "\xC2\xA1Hola!"; // 7 bytes (6 characters in UTF-8) echo $str."\n"; hex_dump($str); echo"\n"; hex_dump(mb_convert_encoding($str, 'UTF-32', 'UTF-8')); echo"\n"; hex_dump(iconv('UTF-8', 'UTF-32', $str)); echo"\n"; hex_dump(mb_convert_encoding(mb_convert_encoding($str, 'UTF-32', 'UTF-8'), 'UTF-8', 'UTF-32'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rvYb1
function name:  (null)
number of ops:  39
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   ASSIGN                                                   !0, '%C2%A1Hola%21'
   34     1        CONCAT                                           ~2      !0, '%0A'
          2        ECHO                                                     ~2
   36     3        INIT_FCALL                                               'hex_dump'
          4        SEND_VAR                                                 !0
          5        DO_FCALL                                      0          
   37     6        ECHO                                                     '%0A'
   38     7        INIT_FCALL                                               'hex_dump'
          8        INIT_FCALL                                               'mb_convert_encoding'
          9        SEND_VAR                                                 !0
         10        SEND_VAL                                                 'UTF-32'
         11        SEND_VAL                                                 'UTF-8'
         12        DO_ICALL                                         $4      
         13        SEND_VAR                                                 $4
         14        DO_FCALL                                      0          
   39    15        ECHO                                                     '%0A'
   40    16        INIT_FCALL                                               'hex_dump'
         17        INIT_FCALL_BY_NAME                                       'iconv'
         18        SEND_VAL_EX                                              'UTF-8'
         19        SEND_VAL_EX                                              'UTF-32'
         20        SEND_VAR_EX                                              !0
         21        DO_FCALL                                      0  $6      
         22        SEND_VAR                                                 $6
         23        DO_FCALL                                      0          
   41    24        ECHO                                                     '%0A'
   42    25        INIT_FCALL                                               'hex_dump'
         26        INIT_FCALL                                               'mb_convert_encoding'
         27        INIT_FCALL                                               'mb_convert_encoding'
         28        SEND_VAR                                                 !0
         29        SEND_VAL                                                 'UTF-32'
         30        SEND_VAL                                                 'UTF-8'
         31        DO_ICALL                                         $8      
         32        SEND_VAR                                                 $8
         33        SEND_VAL                                                 'UTF-8'
         34        SEND_VAL                                                 'UTF-32'
         35        DO_ICALL                                         $9      
         36        SEND_VAR                                                 $9
         37        DO_FCALL                                      0          
         38      > RETURN                                                   1

Function hex_dump:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 29
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 10
Branch analysis from position: 29
2 jumps found. (Code = 77) Position 1 = 50, Position 2 = 74
Branch analysis from position: 50
2 jumps found. (Code = 78) Position 1 = 51, Position 2 = 74
Branch analysis from position: 51
1 jumps found. (Code = 42) Position 1 = 50
Branch analysis from position: 50
Branch analysis from position: 74
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 74
Branch analysis from position: 10
2 jumps found. (Code = 46) Position 1 = 16, Position 2 = 18
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 24
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 10
Branch analysis from position: 29
Branch analysis from position: 10
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 10
Branch analysis from position: 29
Branch analysis from position: 10
Branch analysis from position: 18
Branch analysis from position: 29
filename:       /in/rvYb1
function name:  hex_dump
number of ops:  76
compiled vars:  !0 = $data, !1 = $newline, !2 = $from, !3 = $to, !4 = $width, !5 = $pad, !6 = $i, !7 = $hex, !8 = $chars, !9 = $offset, !10 = $line
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      '%0A'
    5     2        BIND_STATIC                                              !2
    6     3        BIND_STATIC                                              !3
    8     4        BIND_STATIC                                              !4
   10     5        BIND_STATIC                                              !5
   12     6        IS_IDENTICAL                                             !2, ''
          7      > JMPZ                                                     ~11, ->29
   14     8    >   ASSIGN                                                   !6, 0
          9      > JMP                                                      ->27
   16    10    >   INIT_FCALL                                               'chr'
         11        SEND_VAR                                                 !6
         12        DO_ICALL                                         $13     
         13        ASSIGN_OP                                     8          !2, $13
   17    14        IS_SMALLER_OR_EQUAL                              ~15     32, !6
         15      > JMPZ_EX                                          ~15     ~15, ->18
         16    >   IS_SMALLER_OR_EQUAL                              ~16     !6, 126
         17        BOOL                                             ~15     ~16
         18    > > JMPZ                                                     ~15, ->24
         19    >   INIT_FCALL                                               'chr'
         20        SEND_VAR                                                 !6
         21        DO_ICALL                                         $17     
         22        QM_ASSIGN                                        ~18     $17
         23      > JMP                                                      ->25
         24    >   QM_ASSIGN                                        ~18     !5
         25    >   ASSIGN_OP                                     8          !3, ~18
   14    26        PRE_INC                                                  !6
         27    >   IS_SMALLER_OR_EQUAL                                      !6, 255
         28      > JMPNZ                                                    ~21, ->10
   21    29    >   INIT_FCALL                                               'str_split'
         30        INIT_FCALL                                               'bin2hex'
         31        SEND_VAR                                                 !0
         32        DO_ICALL                                         $22     
         33        SEND_VAR                                                 $22
         34        MUL                                              ~23     !4, 2
         35        SEND_VAL                                                 ~23
         36        DO_ICALL                                         $24     
         37        ASSIGN                                                   !7, $24
   22    38        INIT_FCALL                                               'str_split'
         39        INIT_FCALL                                               'strtr'
         40        SEND_VAR                                                 !0
         41        SEND_VAR                                                 !2
         42        SEND_VAR                                                 !3
         43        DO_ICALL                                         $26     
         44        SEND_VAR                                                 $26
         45        SEND_VAR                                                 !4
         46        DO_ICALL                                         $27     
         47        ASSIGN                                                   !8, $27
   24    48        ASSIGN                                                   !9, 0
   25    49      > FE_RESET_R                                       $30     !7, ->74
         50    > > FE_FETCH_R                                       ~31     $30, !10, ->74
         51    >   ASSIGN                                                   !6, ~31
   27    52        INIT_FCALL                                               'sprintf'
         53        SEND_VAL                                                 '%256X'
         54        SEND_VAR                                                 !9
         55        DO_ICALL                                         $33     
         56        CONCAT                                           ~34     $33, '+%3A+'
         57        INIT_FCALL                                               'implode'
         58        SEND_VAL                                                 '+'
         59        INIT_FCALL                                               'str_split'
         60        SEND_VAR                                                 !10
         61        SEND_VAL                                                 2
         62        DO_ICALL                                         $35     
         63        SEND_VAR                                                 $35
         64        DO_ICALL                                         $36     
         65        CONCAT                                           ~37     ~34, $36
         66        CONCAT                                           ~38     ~37, '+%5B'
         67        FETCH_DIM_R                                      ~39     !8, !6
         68        CONCAT                                           ~40     ~38, ~39
         69        CONCAT                                           ~41     ~40, '%5D'
         70        CONCAT                                           ~42     ~41, !1
         71        ECHO                                                     ~42
   28    72        ASSIGN_OP                                     1          !9, !4
   25    73      > JMP                                                      ->50
         74    >   FE_FREE                                                  $30
   30    75      > RETURN                                                   null

End of function hex_dump

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.55 ms | 1407 KiB | 31 Q