3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Bijective { /** * * @var string */ private $dictionary = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; /** * CTOR */ public function __construct() { $this->dictionary = str_split($this->dictionary); } /** * * @param int $i * @return string */ public function encode($i) { if ($i == 0) return $this->dictionary[0]; $result = ''; $base = count($this->dictionary); while ($i > 0) { $result[] = $this->dictionary[($i % $base)]; $i = floor($i / $base); } $result = array_reverse($result); return join("", $result); } /** * * @param string $input * @return int */ public function decode($input) { $i = 0; $base = count($this->dictionary); $input = str_split($input); foreach ($input as $char) { $pos = array_search($char, $this->dictionary); $i = $i * $base + $pos; } return $i; } } $b=new Bijective();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CoU3G
function name:  (null)
number of ops:  4
compiled vars:  !0 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   62     0  E >   NEW                                              $1      'Bijective'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
          3      > RETURN                                                   1

Class Bijective:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CoU3G
function name:  __construct
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   INIT_FCALL                                               'str_split'
          1        FETCH_OBJ_R                                      ~1      'dictionary'
          2        SEND_VAL                                                 ~1
          3        DO_ICALL                                         $2      
          4        ASSIGN_OBJ                                               'dictionary'
          5        OP_DATA                                                  $2
   16     6      > RETURN                                                   null

End of function __construct

Function encode:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 11
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 11
Branch analysis from position: 23
Branch analysis from position: 11
filename:       /in/CoU3G
function name:  encode
number of ops:  33
compiled vars:  !0 = $i, !1 = $result, !2 = $base
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
   24     1        IS_EQUAL                                                 !0, 0
          2      > JMPZ                                                     ~3, ->6
   25     3    >   FETCH_OBJ_R                                      ~4      'dictionary'
          4        FETCH_DIM_R                                      ~5      ~4, 0
          5      > RETURN                                                   ~5
   27     6    >   ASSIGN                                                   !1, ''
   28     7        FETCH_OBJ_R                                      ~7      'dictionary'
          8        COUNT                                            ~8      ~7
          9        ASSIGN                                                   !2, ~8
   30    10      > JMP                                                      ->21
   31    11    >   MOD                                              ~12     !0, !2
         12        FETCH_OBJ_R                                      ~11     'dictionary'
         13        FETCH_DIM_R                                      ~13     ~11, ~12
         14        ASSIGN_DIM                                               !1
         15        OP_DATA                                                  ~13
   32    16        INIT_FCALL                                               'floor'
         17        DIV                                              ~14     !0, !2
         18        SEND_VAL                                                 ~14
         19        DO_ICALL                                         $15     
         20        ASSIGN                                                   !0, $15
   30    21    >   IS_SMALLER                                               0, !0
         22      > JMPNZ                                                    ~17, ->11
   35    23    >   INIT_FCALL                                               'array_reverse'
         24        SEND_VAR                                                 !1
         25        DO_ICALL                                         $18     
         26        ASSIGN                                                   !1, $18
   37    27        INIT_FCALL                                               'join'
         28        SEND_VAL                                                 ''
         29        SEND_VAR                                                 !1
         30        DO_ICALL                                         $20     
         31      > RETURN                                                   $20
   38    32*     > RETURN                                                   null

End of function encode

Function decode:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 21
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 21
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/CoU3G
function name:  decode
number of ops:  24
compiled vars:  !0 = $input, !1 = $i, !2 = $base, !3 = $char, !4 = $pos
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   RECV                                             !0      
   46     1        ASSIGN                                                   !1, 0
   47     2        FETCH_OBJ_R                                      ~6      'dictionary'
          3        COUNT                                            ~7      ~6
          4        ASSIGN                                                   !2, ~7
   49     5        INIT_FCALL                                               'str_split'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $9      
          8        ASSIGN                                                   !0, $9
   51     9      > FE_RESET_R                                       $11     !0, ->21
         10    > > FE_FETCH_R                                               $11, !3, ->21
   52    11    >   INIT_FCALL                                               'array_search'
         12        SEND_VAR                                                 !3
         13        FETCH_OBJ_R                                      ~12     'dictionary'
         14        SEND_VAL                                                 ~12
         15        DO_ICALL                                         $13     
         16        ASSIGN                                                   !4, $13
   54    17        MUL                                              ~15     !1, !2
         18        ADD                                              ~16     ~15, !4
         19        ASSIGN                                                   !1, ~16
   51    20      > JMP                                                      ->10
         21    >   FE_FREE                                                  $11
   57    22      > RETURN                                                   !1
   58    23*     > RETURN                                                   null

End of function decode

End of class Bijective.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.36 ms | 1400 KiB | 23 Q