3v4l.org

run code in 300+ PHP versions simultaneously
<?php function pack_encode($val) { $str = ''; while ($val > 0) { $str .= chr($val & 0xFF); $val = $val >> 8; } // "/" json-encodes poorly and "=" is padding return str_replace( array('/', '='), array('_', ''), base64_encode($str) ); } for ($i=0; $i<32; $i++) { echo pack_encode((1<<$i) + 1) . "\n"; } /* $arr = array(); $packed = pack('N', 32767); for ($i=0; $i<strlen($packed); $i++) { $arr[$i] = ord($packed[$i]); } print_r($arr); function pack_encode($val) { $b64 = base64_encode(pack($format, $val)); return str_replace(array('/', '='), array('_', ''), $b64); // "/" json-encodes poorly and "=" is padding } function pack_decode($bin) { $b64 = str_replace('_', '/', $bin); // un-padded $data = unpack('C'.(length($bin)/2), base64_decode($b64, false)); $val = 0; foreach ($data as $v) { $val = ($val<<$width) | $v; } return $val; } $max = 32767; $n = 20; $step = intval($max/$n); for ($i=0; $i<=$n; $i++) { $val = $i*$step; $enc = pack_encode($val); $dec = pack_decode($val); echo "$enc $dec $val\n"; } */
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 2
Branch analysis from position: 12
Branch analysis from position: 2
filename:       /in/2Av0v
function name:  (null)
number of ops:  13
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   ASSIGN                                                   !0, 0
          1      > JMP                                                      ->10
   18     2    >   INIT_FCALL                                               'pack_encode'
          3        SL                                               ~2      1, !0
          4        ADD                                              ~3      ~2, 1
          5        SEND_VAL                                                 ~3
          6        DO_FCALL                                      0  $4      
          7        CONCAT                                           ~5      $4, '%0A'
          8        ECHO                                                     ~5
   17     9        PRE_INC                                                  !0
         10    >   IS_SMALLER                                               !0, 32
         11      > JMPNZ                                                    ~7, ->2
   54    12    > > RETURN                                                   1

Function pack_encode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 3
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 3
Branch analysis from position: 12
Branch analysis from position: 3
filename:       /in/2Av0v
function name:  pack_encode
number of ops:  22
compiled vars:  !0 = $val, !1 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        ASSIGN                                                   !1, ''
    5     2      > JMP                                                      ->10
    6     3    >   INIT_FCALL                                               'chr'
          4        BW_AND                                           ~3      !0, 255
          5        SEND_VAL                                                 ~3
          6        DO_ICALL                                         $4      
          7        ASSIGN_OP                                     8          !1, $4
    7     8        SR                                               ~6      !0, 8
          9        ASSIGN                                                   !0, ~6
    5    10    >   IS_SMALLER                                               0, !0
         11      > JMPNZ                                                    ~8, ->3
   10    12    >   INIT_FCALL                                               'str_replace'
   11    13        SEND_VAL                                                 <array>
   12    14        SEND_VAL                                                 <array>
   13    15        INIT_FCALL                                               'base64_encode'
         16        SEND_VAR                                                 !1
         17        DO_ICALL                                         $9      
         18        SEND_VAR                                                 $9
         19        DO_ICALL                                         $10     
         20      > RETURN                                                   $10
   15    21*     > RETURN                                                   null

End of function pack_encode

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.16 ms | 1394 KiB | 20 Q