3v4l.org

run code in 300+ PHP versions simultaneously
<?php class base62{ /** * 10进制转为62进制 * @param integer $n 10进制数值 * @return string 62进制 */ function base10to62($n) { $base = 62; $index = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $ret = ''; for($t = floor(log10($n) / log10($base)); $t >= 0; $t --) { $a = floor($n / pow($base, $t)); $ret .= substr($index, $a, 1); $n -= $a * pow($base, $t); } return $ret; } /** * 62进制转为10进制 * @param integer $n 62进制 * @return string 10进制 */ function base62to10($s) { $base = 62; $index = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $ret = 0; $len = strlen($s) - 1; for($t = 0; $t <= $len; $t ++) { $ret += strpos($index, substr($s, $t, 1)) * pow($base, $len - $t); } return $ret; } } $base = new base62; echo $base->base10to62("3819313952083157"); function base62($x){ $show=''; while($x>0){ $s= $x%62; if ($s>35) { $s= chr($s+61); }elseif ($s>9&&$s<=35){ $s=chr($s+55); } $show.=$s; $x=floor($x/62); } return $show; } echo base62("3819313952083157");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ote3u
function name:  (null)
number of ops:  12
compiled vars:  !0 = $base
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   NEW                                              $1      'base62'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   37     3        INIT_METHOD_CALL                                         !0, 'base10to62'
          4        SEND_VAL_EX                                              '3819313952083157'
          5        DO_FCALL                                      0  $4      
          6        ECHO                                                     $4
   54     7        INIT_FCALL                                               'base62'
          8        SEND_VAL                                                 '3819313952083157'
          9        DO_FCALL                                      0  $5      
         10        ECHO                                                     $5
         11      > RETURN                                                   1

Function base62:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 3
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 13
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 3
Branch analysis from position: 31
Branch analysis from position: 3
Branch analysis from position: 13
2 jumps found. (Code = 46) Position 1 = 15, Position 2 = 17
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 23
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 3
Branch analysis from position: 31
Branch analysis from position: 3
Branch analysis from position: 23
Branch analysis from position: 17
filename:       /in/ote3u
function name:  base62
number of ops:  33
compiled vars:  !0 = $x, !1 = $show, !2 = $s
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   RECV                                             !0      
   40     1        ASSIGN                                                   !1, ''
   41     2      > JMP                                                      ->29
   42     3    >   MOD                                              ~4      !0, 62
          4        ASSIGN                                                   !2, ~4
   43     5        IS_SMALLER                                               35, !2
          6      > JMPZ                                                     ~6, ->13
   44     7    >   INIT_FCALL                                               'chr'
          8        ADD                                              ~7      !2, 61
          9        SEND_VAL                                                 ~7
         10        DO_ICALL                                         $8      
         11        ASSIGN                                                   !2, $8
         12      > JMP                                                      ->23
   45    13    >   IS_SMALLER                                       ~10     9, !2
         14      > JMPZ_EX                                          ~10     ~10, ->17
         15    >   IS_SMALLER_OR_EQUAL                              ~11     !2, 35
         16        BOOL                                             ~10     ~11
         17    > > JMPZ                                                     ~10, ->23
   46    18    >   INIT_FCALL                                               'chr'
         19        ADD                                              ~12     !2, 55
         20        SEND_VAL                                                 ~12
         21        DO_ICALL                                         $13     
         22        ASSIGN                                                   !2, $13
   48    23    >   ASSIGN_OP                                     8          !1, !2
   49    24        INIT_FCALL                                               'floor'
         25        DIV                                              ~16     !0, 62
         26        SEND_VAL                                                 ~16
         27        DO_ICALL                                         $17     
         28        ASSIGN                                                   !0, $17
   41    29    >   IS_SMALLER                                               0, !0
         30      > JMPNZ                                                    ~19, ->3
   51    31    > > RETURN                                                   !1
   52    32*     > RETURN                                                   null

End of function base62

Class base62:
Function base10to62:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 16
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 16
Branch analysis from position: 40
Branch analysis from position: 16
filename:       /in/ote3u
function name:  base10to62
number of ops:  42
compiled vars:  !0 = $n, !1 = $base, !2 = $index, !3 = $ret, !4 = $t, !5 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
    9     1        ASSIGN                                                   !1, 62
   10     2        ASSIGN                                                   !2, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
   11     3        ASSIGN                                                   !3, ''
   12     4        INIT_FCALL                                               'floor'
          5        INIT_FCALL                                               'log10'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $9      
          8        INIT_FCALL                                               'log10'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                         $10     
         11        DIV                                              ~11     $9, $10
         12        SEND_VAL                                                 ~11
         13        DO_ICALL                                         $12     
         14        ASSIGN                                                   !4, $12
         15      > JMP                                                      ->38
   13    16    >   INIT_FCALL                                               'floor'
         17        INIT_FCALL                                               'pow'
         18        SEND_VAR                                                 !1
         19        SEND_VAR                                                 !4
         20        DO_ICALL                                         $14     
         21        DIV                                              ~15     !0, $14
         22        SEND_VAL                                                 ~15
         23        DO_ICALL                                         $16     
         24        ASSIGN                                                   !5, $16
   14    25        INIT_FCALL                                               'substr'
         26        SEND_VAR                                                 !2
         27        SEND_VAR                                                 !5
         28        SEND_VAL                                                 1
         29        DO_ICALL                                         $18     
         30        ASSIGN_OP                                     8          !3, $18
   15    31        INIT_FCALL                                               'pow'
         32        SEND_VAR                                                 !1
         33        SEND_VAR                                                 !4
         34        DO_ICALL                                         $20     
         35        MUL                                              ~21     !5, $20
         36        ASSIGN_OP                                     2          !0, ~21
   12    37        PRE_DEC                                                  !4
         38    >   IS_SMALLER_OR_EQUAL                                      0, !4
         39      > JMPNZ                                                    ~24, ->16
   17    40    > > RETURN                                                   !3
   18    41*     > RETURN                                                   null

End of function base10to62

Function base62to10:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 9
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 9
Branch analysis from position: 28
Branch analysis from position: 9
filename:       /in/ote3u
function name:  base62to10
number of ops:  30
compiled vars:  !0 = $s, !1 = $base, !2 = $index, !3 = $ret, !4 = $len, !5 = $t
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
   26     1        ASSIGN                                                   !1, 62
   27     2        ASSIGN                                                   !2, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
   28     3        ASSIGN                                                   !3, 0
   29     4        STRLEN                                           ~9      !0
          5        SUB                                              ~10     ~9, 1
          6        ASSIGN                                                   !4, ~10
   30     7        ASSIGN                                                   !5, 0
          8      > JMP                                                      ->26
   31     9    >   INIT_FCALL                                               'strpos'
         10        SEND_VAR                                                 !2
         11        INIT_FCALL                                               'substr'
         12        SEND_VAR                                                 !0
         13        SEND_VAR                                                 !5
         14        SEND_VAL                                                 1
         15        DO_ICALL                                         $13     
         16        SEND_VAR                                                 $13
         17        DO_ICALL                                         $14     
         18        INIT_FCALL                                               'pow'
         19        SEND_VAR                                                 !1
         20        SUB                                              ~15     !4, !5
         21        SEND_VAL                                                 ~15
         22        DO_ICALL                                         $16     
         23        MUL                                              ~17     $14, $16
         24        ASSIGN_OP                                     1          !3, ~17
   30    25        PRE_INC                                                  !5
         26    >   IS_SMALLER_OR_EQUAL                                      !5, !4
         27      > JMPNZ                                                    ~20, ->9
   33    28    > > RETURN                                                   !3
   34    29*     > RETURN                                                   null

End of function base62to10

End of class base62.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
189.21 ms | 1411 KiB | 26 Q