3v4l.org

run code in 300+ PHP versions simultaneously
<?php function dec_to_hex($dec) { $sign = ""; // suppress errors if( $dec < 0){ $sign = "-"; $dec = abs($dec); } $hex = Array( 0 => 0, 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 'a', 11 => 'b', 12 => 'c', 13 => 'd', 14 => 'e', 15 => 'f' ); do { $h = $hex[($dec%16)] . $h; $dec /= 16; } while( $dec >= 1 ); return $sign . $h; } function dec2hex($number) { $number = strval($number); $hexvalues = array( '0','1','2','3','4','5','6','7', '8','9','A','B','C','D','E','F' ); $hexval = ''; while($number != '0') { $hexval = $hexvalues[bcmod($number, '16')] . $hexval; $number = bcdiv($number, '16', 0); } return $hexval; } $id = 14910855968770314426; var_dump($id); $guid = dec_to_hex($id); var_dump($guid);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mqu5P
function name:  (null)
number of ops:  12
compiled vars:  !0 = $id, !1 = $guid
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   ASSIGN                                                   !0, 1.49109e+19
   42     1        INIT_FCALL                                               'var_dump'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                                 
   43     4        INIT_FCALL                                               'dec_to_hex'
          5        SEND_VAR                                                 !0
          6        DO_FCALL                                      0  $4      
          7        ASSIGN                                                   !1, $4
   44     8        INIT_FCALL                                               'var_dump'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                                 
         11      > RETURN                                                   1

Function dec_to_hex:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 10
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
Branch analysis from position: 9
filename:       /in/mqu5P
function name:  dec_to_hex
number of ops:  20
compiled vars:  !0 = $dec, !1 = $sign, !2 = $hex, !3 = $h
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        ASSIGN                                                   !1, ''
    6     2        IS_SMALLER                                               !0, 0
          3      > JMPZ                                                     ~5, ->9
          4    >   ASSIGN                                                   !1, '-'
          5        INIT_FCALL                                               'abs'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $7      
          8        ASSIGN                                                   !0, $7
    8     9    >   ASSIGN                                                   !2, <array>
   15    10    >   MOD                                              ~10     !0, 16
         11        FETCH_DIM_R                                      ~11     !2, ~10
         12        CONCAT                                           ~12     ~11, !3
         13        ASSIGN                                                   !3, ~12
   16    14        ASSIGN_OP                                     4          !0, 16
   18    15        IS_SMALLER_OR_EQUAL                                      1, !0
         16      > JMPNZ                                                    ~15, ->10
   20    17    >   CONCAT                                           ~16     !1, !3
         18      > RETURN                                                   ~16
   21    19*     > RETURN                                                   null

End of function dec_to_hex

Function dec2hex:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 6
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 6
Branch analysis from position: 21
Branch analysis from position: 6
filename:       /in/mqu5P
function name:  dec2hex
number of ops:  23
compiled vars:  !0 = $number, !1 = $hexvalues, !2 = $hexval
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
   25     1        CAST                                          6  ~3      !0
          2        ASSIGN                                                   !0, ~3
   26     3        ASSIGN                                                   !1, <array>
   31     4        ASSIGN                                                   !2, ''
   33     5      > JMP                                                      ->19
   34     6    >   INIT_FCALL_BY_NAME                                       'bcmod'
          7        SEND_VAR_EX                                              !0
          8        SEND_VAL_EX                                              '16'
          9        DO_FCALL                                      0  $7      
         10        FETCH_DIM_R                                      ~8      !1, $7
         11        CONCAT                                           ~9      ~8, !2
         12        ASSIGN                                                   !2, ~9
   35    13        INIT_FCALL_BY_NAME                                       'bcdiv'
         14        SEND_VAR_EX                                              !0
         15        SEND_VAL_EX                                              '16'
         16        SEND_VAL_EX                                              0
         17        DO_FCALL                                      0  $11     
         18        ASSIGN                                                   !0, $11
   33    19    >   IS_NOT_EQUAL                                             !0, '0'
         20      > JMPNZ                                                    ~13, ->6
   38    21    > > RETURN                                                   !2
   39    22*     > RETURN                                                   null

End of function dec2hex

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.06 ms | 1403 KiB | 24 Q