3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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
Jump found. Position 1 = -2
filename:       /in/CoU3G
function name:  (null)
number of ops:  5
compiled vars:  !0 = $b
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   NOP                                                      
  62     1        NEW                                              $2      :-6
         2        DO_FCALL                                      0          
         3        ASSIGN                                                   !0, $2
         4      > RETURN                                                   1

Class Bijective:
Function __construct:
Finding entry points
Branch analysis from position: 0
Jump found. 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_VAR                                                 $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
Jump found. Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
Jump found. Position 1 = -2
Branch analysis from position: 6
Jump found. Position 1 = 23
Branch analysis from position: 23
Jump found. Position 1 = 25, Position 2 = 13
Branch analysis from position: 25
Jump found. Position 1 = -2
Branch analysis from position: 13
Jump found. Position 1 = 25, Position 2 = 13
Branch analysis from position: 25
Branch analysis from position: 13
filename:       /in/CoU3G
function name:  encode
number of ops:  35
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                                         ~3      !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        INIT_FCALL                                               'count'
         8        FETCH_OBJ_R                                      $7      'dictionary'
         9        SEND_VAR                                                 $7
        10        DO_ICALL                                         $8      
        11        ASSIGN                                                   !2, $8
  30    12      > JMP                                                      ->23
  31    13    >   MOD                                              ~12     !0, !2
        14        FETCH_OBJ_R                                      $11     'dictionary'
        15        FETCH_DIM_R                                      $13     $11, ~12
        16        ASSIGN_DIM                                               !1
        17        OP_DATA                                                  $13
  32    18        INIT_FCALL                                               'floor'
        19        DIV                                              ~14     !0, !2
        20        SEND_VAL                                                 ~14
        21        DO_ICALL                                         $15     
        22        ASSIGN                                                   !0, $15
  30    23    >   IS_SMALLER                                       ~17     0, !0
        24      > JMPNZ                                                    ~17, ->13
  35    25    >   INIT_FCALL                                               'array_reverse'
        26        SEND_VAR                                                 !1
        27        DO_ICALL                                         $18     
        28        ASSIGN                                                   !1, $18
  37    29        INIT_FCALL                                               'join'
        30        SEND_VAL                                                 ''
        31        SEND_VAR                                                 !1
        32        DO_ICALL                                         $20     
        33      > RETURN                                                   $20
  38    34*     > RETURN                                                   null

End of function encode

Function decode:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = 12, Position 2 = 23
Branch analysis from position: 12
Jump found. Position 1 = 13, Position 2 = 23
Branch analysis from position: 13
Jump found. Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 23
Jump found. Position 1 = -2
Branch analysis from position: 23
filename:       /in/CoU3G
function name:  decode
number of ops:  26
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        INIT_FCALL                                               'count'
         3        FETCH_OBJ_R                                      $6      'dictionary'
         4        SEND_VAR                                                 $6
         5        DO_ICALL                                         $7      
         6        ASSIGN                                                   !2, $7
  49     7        INIT_FCALL                                               'str_split'
         8        SEND_VAR                                                 !0
         9        DO_ICALL                                         $9      
        10        ASSIGN                                                   !0, $9
  51    11      > FE_RESET_R                                       $11     !0, ->23
        12    > > FE_FETCH_R                                               $11, !3, ->23
  52    13    >   INIT_FCALL                                               'array_search'
        14        SEND_VAR                                                 !3
        15        FETCH_OBJ_R                                      $12     'dictionary'
        16        SEND_VAR                                                 $12
        17        DO_ICALL                                         $13     
        18        ASSIGN                                                   !4, $13
  54    19        MUL                                              ~15     !1, !2
        20        ADD                                              ~16     ~15, !4
        21        ASSIGN                                                   !1, ~16
        22      > JMP                                                      ->12
        23    >   FE_FREE                                                  $11
  57    24      > RETURN                                                   !1
  58    25*     > RETURN                                                   null

End of function decode

End of class Bijective.

Generated using Vulcan Logic Dumper, using php 7.3.0