3v4l.org

run code in 300+ PHP versions simultaneously
<?php function convertVersionId($versionId, $base) { return sprintf( '%d.%d.%d', $versionId / ($base * $base), ($versionId / $base) % $base, $versionId % $base ); } function convertVersionIdFixed($versionId, $base) { return sprintf( '%d.%d.%d', $versionId / ($base * $base), (int) ($versionId / $base) % $base, $versionId % $base ); } var_dump(convertVersionId(30411, 100)); var_dump(convertVersionId(20449, 100)); echo '-----------', PHP_EOL; var_dump(convertVersionIdFixed(30411, 100)); var_dump(convertVersionIdFixed(20449, 100));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1fr2g
function name:  (null)
number of ops:  31
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'convertversionid'
          2        SEND_VAL                                                 30411
          3        SEND_VAL                                                 100
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
   24     7        INIT_FCALL                                               'var_dump'
          8        INIT_FCALL                                               'convertversionid'
          9        SEND_VAL                                                 20449
         10        SEND_VAL                                                 100
         11        DO_FCALL                                      0  $2      
         12        SEND_VAR                                                 $2
         13        DO_ICALL                                                 
   25    14        ECHO                                                     '-----------'
         15        ECHO                                                     '%0A'
   26    16        INIT_FCALL                                               'var_dump'
         17        INIT_FCALL                                               'convertversionidfixed'
         18        SEND_VAL                                                 30411
         19        SEND_VAL                                                 100
         20        DO_FCALL                                      0  $4      
         21        SEND_VAR                                                 $4
         22        DO_ICALL                                                 
   27    23        INIT_FCALL                                               'var_dump'
         24        INIT_FCALL                                               'convertversionidfixed'
         25        SEND_VAL                                                 20449
         26        SEND_VAL                                                 100
         27        DO_FCALL                                      0  $6      
         28        SEND_VAR                                                 $6
         29        DO_ICALL                                                 
         30      > RETURN                                                   1

Function convertversionid:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1fr2g
function name:  convertVersionId
number of ops:  15
compiled vars:  !0 = $versionId, !1 = $base
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        INIT_FCALL                                               'sprintf'
    6     3        SEND_VAL                                                 '%25d.%25d.%25d'
    7     4        MUL                                              ~2      !1, !1
          5        DIV                                              ~3      !0, ~2
          6        SEND_VAL                                                 ~3
    8     7        DIV                                              ~4      !0, !1
          8        MOD                                              ~5      ~4, !1
          9        SEND_VAL                                                 ~5
    9    10        MOD                                              ~6      !0, !1
         11        SEND_VAL                                                 ~6
         12        DO_ICALL                                         $7      
         13      > RETURN                                                   $7
   11    14*     > RETURN                                                   null

End of function convertversionid

Function convertversionidfixed:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1fr2g
function name:  convertVersionIdFixed
number of ops:  16
compiled vars:  !0 = $versionId, !1 = $base
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   15     2        INIT_FCALL                                               'sprintf'
   16     3        SEND_VAL                                                 '%25d.%25d.%25d'
   17     4        MUL                                              ~2      !1, !1
          5        DIV                                              ~3      !0, ~2
          6        SEND_VAL                                                 ~3
   18     7        DIV                                              ~4      !0, !1
          8        CAST                                          4  ~5      ~4
          9        MOD                                              ~6      ~5, !1
         10        SEND_VAL                                                 ~6
   19    11        MOD                                              ~7      !0, !1
         12        SEND_VAL                                                 ~7
         13        DO_ICALL                                         $8      
         14      > RETURN                                                   $8
   21    15*     > RETURN                                                   null

End of function convertversionidfixed

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
132.18 ms | 1417 KiB | 21 Q