3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo{ public static $alphabet = 'ABCDEFGHIKLMNOPQRSTVXYZabcdefghiklmnopqrstvxyz'; public static function shorten($number) { $alphabet = self::$alphabet; $base = strlen($alphabet); $number = intval($number, 10); $shortened = ""; while ($number > 0) { $remainder = $number % $base; $shortened = $alphabet[$remainder] . $shortened; $number = (int) ($number / $base); } return $shortened; } public static function unshorten($string) { $alphabet = self::$alphabet; $base = strlen($alphabet); $length = strlen($string); $returnVal = 0; for ($i=$length-1; $i >= 0; --$i) { $ind = strpos($alphabet, $string[$i]); if ($ind === false) { return false; } $returnVal += (int)($ind * pow($base, $i)); } return $returnVal; } } $shortened = Foo::shorten(12343336363636636); echo $shortened . "\n"; var_dump(Foo::unshorten($shortened));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hBf59
function name:  (null)
number of ops:  13
compiled vars:  !0 = $shortened
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   INIT_STATIC_METHOD_CALL                                  'Foo', 'shorten'
          1        SEND_VAL                                                 12343336363636636
          2        DO_FCALL                                      0  $1      
          3        ASSIGN                                                   !0, $1
   37     4        CONCAT                                           ~3      !0, '%0A'
          5        ECHO                                                     ~3
   38     6        INIT_FCALL                                               'var_dump'
          7        INIT_STATIC_METHOD_CALL                                  'Foo', 'unshorten'
          8        SEND_VAR                                                 !0
          9        DO_FCALL                                      0  $4      
         10        SEND_VAR                                                 $4
         11        DO_ICALL                                                 
         12      > RETURN                                                   1

Class Foo:
Function shorten:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 12
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 12
Branch analysis from position: 22
Branch analysis from position: 12
filename:       /in/hBf59
function name:  shorten
number of ops:  24
compiled vars:  !0 = $number, !1 = $alphabet, !2 = $base, !3 = $shortened, !4 = $remainder
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        FETCH_STATIC_PROP_R          unknown             ~5      'alphabet'
          2        ASSIGN                                                   !1, ~5
    9     3        STRLEN                                           ~7      !1
          4        ASSIGN                                                   !2, ~7
   10     5        INIT_FCALL                                               'intval'
          6        SEND_VAR                                                 !0
          7        SEND_VAL                                                 10
          8        DO_ICALL                                         $9      
          9        ASSIGN                                                   !0, $9
   11    10        ASSIGN                                                   !3, ''
   12    11      > JMP                                                      ->20
   13    12    >   MOD                                              ~12     !0, !2
         13        ASSIGN                                                   !4, ~12
   14    14        FETCH_DIM_R                                      ~14     !1, !4
         15        CONCAT                                           ~15     ~14, !3
         16        ASSIGN                                                   !3, ~15
   15    17        DIV                                              ~17     !0, !2
         18        CAST                                          4  ~18     ~17
         19        ASSIGN                                                   !0, ~18
   12    20    >   IS_SMALLER                                               0, !0
         21      > JMPNZ                                                    ~20, ->12
   17    22    > > RETURN                                                   !3
   19    23*     > RETURN                                                   null

End of function shorten

Function unshorten:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 11
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 20
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 11
Branch analysis from position: 30
Branch analysis from position: 11
filename:       /in/hBf59
function name:  unshorten
number of ops:  32
compiled vars:  !0 = $string, !1 = $alphabet, !2 = $base, !3 = $length, !4 = $returnVal, !5 = $i, !6 = $ind
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   21     1        FETCH_STATIC_PROP_R          unknown             ~7      'alphabet'
          2        ASSIGN                                                   !1, ~7
   22     3        STRLEN                                           ~9      !1
          4        ASSIGN                                                   !2, ~9
   23     5        STRLEN                                           ~11     !0
          6        ASSIGN                                                   !3, ~11
   24     7        ASSIGN                                                   !4, 0
   25     8        SUB                                              ~14     !3, 1
          9        ASSIGN                                                   !5, ~14
         10      > JMP                                                      ->28
   26    11    >   INIT_FCALL                                               'strpos'
         12        SEND_VAR                                                 !1
         13        FETCH_DIM_R                                      ~16     !0, !5
         14        SEND_VAL                                                 ~16
         15        DO_ICALL                                         $17     
         16        ASSIGN                                                   !6, $17
   27    17        TYPE_CHECK                                    4          !6
         18      > JMPZ                                                     ~19, ->20
   28    19    > > RETURN                                                   <false>
   30    20    >   INIT_FCALL                                               'pow'
         21        SEND_VAR                                                 !2
         22        SEND_VAR                                                 !5
         23        DO_ICALL                                         $20     
         24        MUL                                              ~21     !6, $20
         25        CAST                                          4  ~22     ~21
         26        ASSIGN_OP                                     1          !4, ~22
   25    27        PRE_DEC                                                  !5
         28    >   IS_SMALLER_OR_EQUAL                                      0, !5
         29      > JMPNZ                                                    ~25, ->11
   32    30    > > RETURN                                                   !4
   33    31*     > RETURN                                                   null

End of function unshorten

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.17 ms | 1392 KiB | 21 Q