3v4l.org

run code in 300+ PHP versions simultaneously
<?php function pack_encode($format, $val) { $b64 = base64_encode(pack($format, $val)); return str_replace(array('/', '='), array('_', ''), $b64); } function pack_decode($format, $val) { $b64 = str_replace('_', '/', $val); // un-padded return unpack($format, base64_decode($b64, false)); } function pack_encode_uint16($val) { return pack_encode('S', $val); } function pack_encode_uint32($val) { return pack_encode('N', $val); } function pack_decode_uint16($val) { return pack_decode('S', $val); } function pack_decode_uint32($val) { return pack_decode('N', $val); } $max = 32767; $n = 20; $step = intval($max/$n); for ($i=0; $i<=$n; $i++) { $val = $i*$step; $uint16 = pack_encode_uint16($val); $uint32 = pack_encode_uint32($val); $str = base64_encode(strval($val)); echo json_encode("$uint16 $uint32 $str $val") . "\n"; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 7
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 7
Branch analysis from position: 37
Branch analysis from position: 7
filename:       /in/7qjQg
function name:  (null)
number of ops:  38
compiled vars:  !0 = $max, !1 = $n, !2 = $step, !3 = $i, !4 = $val, !5 = $uint16, !6 = $uint32, !7 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   ASSIGN                                                   !0, 32767
   30     1        ASSIGN                                                   !1, 20
   31     2        DIV                                              ~10     !0, !1
          3        CAST                                          4  ~11     ~10
          4        ASSIGN                                                   !2, ~11
   33     5        ASSIGN                                                   !3, 0
          6      > JMP                                                      ->35
   34     7    >   MUL                                              ~14     !3, !2
          8        ASSIGN                                                   !4, ~14
   35     9        INIT_FCALL                                               'pack_encode_uint16'
         10        SEND_VAR                                                 !4
         11        DO_FCALL                                      0  $16     
         12        ASSIGN                                                   !5, $16
   36    13        INIT_FCALL                                               'pack_encode_uint32'
         14        SEND_VAR                                                 !4
         15        DO_FCALL                                      0  $18     
         16        ASSIGN                                                   !6, $18
   37    17        INIT_FCALL                                               'base64_encode'
         18        CAST                                          6  ~20     !4
         19        SEND_VAL                                                 ~20
         20        DO_ICALL                                         $21     
         21        ASSIGN                                                   !7, $21
   38    22        INIT_FCALL                                               'json_encode'
         23        ROPE_INIT                                     7  ~24     !5
         24        ROPE_ADD                                      1  ~24     ~24, '+'
         25        ROPE_ADD                                      2  ~24     ~24, !6
         26        ROPE_ADD                                      3  ~24     ~24, '+'
         27        ROPE_ADD                                      4  ~24     ~24, !7
         28        ROPE_ADD                                      5  ~24     ~24, '+'
         29        ROPE_END                                      6  ~23     ~24, !4
         30        SEND_VAL                                                 ~23
         31        DO_ICALL                                         $28     
         32        CONCAT                                           ~29     $28, '%0A'
         33        ECHO                                                     ~29
   33    34        PRE_INC                                                  !3
         35    >   IS_SMALLER_OR_EQUAL                                      !3, !1
         36      > JMPNZ                                                    ~31, ->7
   39    37    > > RETURN                                                   1

Function pack_encode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7qjQg
function name:  pack_encode
number of ops:  17
compiled vars:  !0 = $format, !1 = $val, !2 = $b64
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        INIT_FCALL                                               'base64_encode'
          3        INIT_FCALL                                               'pack'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $3      
          7        SEND_VAR                                                 $3
          8        DO_ICALL                                         $4      
          9        ASSIGN                                                   !2, $4
    5    10        INIT_FCALL                                               'str_replace'
         11        SEND_VAL                                                 <array>
         12        SEND_VAL                                                 <array>
         13        SEND_VAR                                                 !2
         14        DO_ICALL                                         $6      
         15      > RETURN                                                   $6
    6    16*     > RETURN                                                   null

End of function pack_encode

Function pack_decode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7qjQg
function name:  pack_decode
number of ops:  18
compiled vars:  !0 = $format, !1 = $val, !2 = $b64
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    9     2        INIT_FCALL                                               'str_replace'
          3        SEND_VAL                                                 '_'
          4        SEND_VAL                                                 '%2F'
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $3      
          7        ASSIGN                                                   !2, $3
   10     8        INIT_FCALL                                               'unpack'
          9        SEND_VAR                                                 !0
         10        INIT_FCALL                                               'base64_decode'
         11        SEND_VAR                                                 !2
         12        SEND_VAL                                                 <false>
         13        DO_ICALL                                         $5      
         14        SEND_VAR                                                 $5
         15        DO_ICALL                                         $6      
         16      > RETURN                                                   $6
   11    17*     > RETURN                                                   null

End of function pack_decode

Function pack_encode_uint16:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7qjQg
function name:  pack_encode_uint16
number of ops:  7
compiled vars:  !0 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        INIT_FCALL                                               'pack_encode'
          2        SEND_VAL                                                 'S'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $1      
          5      > RETURN                                                   $1
   15     6*     > RETURN                                                   null

End of function pack_encode_uint16

Function pack_encode_uint32:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7qjQg
function name:  pack_encode_uint32
number of ops:  7
compiled vars:  !0 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   18     1        INIT_FCALL                                               'pack_encode'
          2        SEND_VAL                                                 'N'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $1      
          5      > RETURN                                                   $1
   19     6*     > RETURN                                                   null

End of function pack_encode_uint32

Function pack_decode_uint16:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7qjQg
function name:  pack_decode_uint16
number of ops:  7
compiled vars:  !0 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   22     1        INIT_FCALL                                               'pack_decode'
          2        SEND_VAL                                                 'S'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $1      
          5      > RETURN                                                   $1
   23     6*     > RETURN                                                   null

End of function pack_decode_uint16

Function pack_decode_uint32:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7qjQg
function name:  pack_decode_uint32
number of ops:  7
compiled vars:  !0 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
   26     1        INIT_FCALL                                               'pack_decode'
          2        SEND_VAL                                                 'N'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $1      
          5      > RETURN                                                   $1
   27     6*     > RETURN                                                   null

End of function pack_decode_uint32

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.83 ms | 1398 KiB | 31 Q