3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getShortUrl(int $id) { $chars = "123456789bcdfghjkmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ"; $length = strlen($chars); $id = intval($id); if ($id < 1) { return 0; } $code = ""; while ($id > $length - 1) { $fmod =intval(fmod($id, $length)); $code =$chars[$fmod].$code; $id = floor($id / $length); } $code = $chars[intval($id)] . $code; return $code; } $short_url=getShortUrl(1499213934773); echo "sinadme.com/".$short_url;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2L8TS
function name:  (null)
number of ops:  7
compiled vars:  !0 = $short_url
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   INIT_FCALL                                               'getshorturl'
          1        SEND_VAL                                                 1499213934773
          2        DO_FCALL                                      0  $1      
          3        ASSIGN                                                   !0, $1
   21     4        CONCAT                                           ~3      'sinadme.com%2F', !0
          5        ECHO                                                     ~3
          6      > RETURN                                                   1

Function getshorturl:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 9
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 11
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 11
Branch analysis from position: 28
Branch analysis from position: 11
filename:       /in/2L8TS
function name:  getShortUrl
number of ops:  34
compiled vars:  !0 = $id, !1 = $chars, !2 = $length, !3 = $code, !4 = $fmod
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        ASSIGN                                                   !1, '123456789bcdfghjkmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ'
    5     2        STRLEN                                           ~6      !1
          3        ASSIGN                                                   !2, ~6
    7     4        CAST                                          4  ~8      !0
          5        ASSIGN                                                   !0, ~8
    8     6        IS_SMALLER                                               !0, 1
          7      > JMPZ                                                     ~10, ->9
    9     8    > > RETURN                                                   0
   11     9    >   ASSIGN                                                   !3, ''
   12    10      > JMP                                                      ->25
   13    11    >   INIT_FCALL                                               'fmod'
         12        SEND_VAR                                                 !0
         13        SEND_VAR                                                 !2
         14        DO_ICALL                                         $12     
         15        CAST                                          4  ~13     $12
         16        ASSIGN                                                   !4, ~13
   14    17        FETCH_DIM_R                                      ~15     !1, !4
         18        CONCAT                                           ~16     ~15, !3
         19        ASSIGN                                                   !3, ~16
   15    20        INIT_FCALL                                               'floor'
         21        DIV                                              ~18     !0, !2
         22        SEND_VAL                                                 ~18
         23        DO_ICALL                                         $19     
         24        ASSIGN                                                   !0, $19
   12    25    >   SUB                                              ~21     !2, 1
         26        IS_SMALLER                                               ~21, !0
         27      > JMPNZ                                                    ~22, ->11
   17    28    >   CAST                                          4  ~23     !0
         29        FETCH_DIM_R                                      ~24     !1, ~23
         30        CONCAT                                           ~25     ~24, !3
         31        ASSIGN                                                   !3, ~25
   18    32      > RETURN                                                   !3
   19    33*     > RETURN                                                   null

End of function getshorturl

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.92 ms | 1403 KiB | 18 Q