3v4l.org

run code in 300+ PHP versions simultaneously
<?php function uuid7(): string { $msec = (int)(microtime(true) * 1000); // 48-bit timestamp (big-endian) $timeBytes = pack("J", $msec); $timeBytes = substr($timeBytes, -6); $rand = random_bytes(10); $bytes = $timeBytes . $rand; // Version 7 $bytes[6] = chr((ord($bytes[6]) & 0x0f) | 0x70); // Variant RFC 4122 (10xx) $bytes[8] = chr((ord($bytes[8]) & 0x3f) | 0x80); $hex = bin2hex($bytes); return sprintf( '%s-%s-%s-%s-%s', substr($hex, 0, 8), substr($hex, 8, 4), substr($hex, 12, 4), substr($hex, 16, 4), substr($hex, 20) ); } for ($i = 0; $i < 100; $i++) { echo uuid7() . PHP_EOL; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 2
Branch analysis from position: 9
Branch analysis from position: 2
filename:       /in/2ATXk
function name:  (null)
number of ops:  10
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   ASSIGN                                                   !0, 0
          1      > JMP                                                      ->7
   33     2    >   INIT_FCALL                                               'uuid7'
          3        DO_FCALL                                      0  $2      
          4        CONCAT                                           ~3      $2, '%0A'
          5        ECHO                                                     ~3
   32     6        PRE_INC                                                  !0
          7    >   IS_SMALLER                                               !0, 100
          8      > JMPNZ                                                    ~5, ->2
   35     9    > > RETURN                                                   1

Function uuid7:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2ATXk
function name:  uuid7
number of ops:  84
compiled vars:  !0 = $msec, !1 = $timeBytes, !2 = $rand, !3 = $bytes, !4 = $hex
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   INIT_FCALL                                               'microtime'
          1        SEND_VAL                                                 <true>
          2        DO_ICALL                                         $5      
          3        MUL                                              ~6      $5, 1000
          4        CAST                                          4  ~7      ~6
          5        ASSIGN                                                   !0, ~7
    8     6        INIT_FCALL                                               'pack'
          7        SEND_VAL                                                 'J'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $9      
         10        ASSIGN                                                   !1, $9
    9    11        INIT_FCALL                                               'substr'
         12        SEND_VAR                                                 !1
         13        SEND_VAL                                                 -6
         14        DO_ICALL                                         $11     
         15        ASSIGN                                                   !1, $11
   11    16        INIT_FCALL                                               'random_bytes'
         17        SEND_VAL                                                 10
         18        DO_ICALL                                         $13     
         19        ASSIGN                                                   !2, $13
   12    20        CONCAT                                           ~15     !1, !2
         21        ASSIGN                                                   !3, ~15
   15    22        INIT_FCALL                                               'chr'
         23        INIT_FCALL                                               'ord'
         24        FETCH_DIM_R                                      ~18     !3, 6
         25        SEND_VAL                                                 ~18
         26        DO_ICALL                                         $19     
         27        BW_AND                                           ~20     $19, 15
         28        BW_OR                                            ~21     ~20, 112
         29        SEND_VAL                                                 ~21
         30        DO_ICALL                                         $22     
         31        ASSIGN_DIM                                               !3, 6
         32        OP_DATA                                                  $22
   18    33        INIT_FCALL                                               'chr'
         34        INIT_FCALL                                               'ord'
         35        FETCH_DIM_R                                      ~24     !3, 8
         36        SEND_VAL                                                 ~24
         37        DO_ICALL                                         $25     
         38        BW_AND                                           ~26     $25, 63
         39        BW_OR                                            ~27     ~26, 128
         40        SEND_VAL                                                 ~27
         41        DO_ICALL                                         $28     
         42        ASSIGN_DIM                                               !3, 8
         43        OP_DATA                                                  $28
   20    44        INIT_FCALL                                               'bin2hex'
         45        SEND_VAR                                                 !3
         46        DO_ICALL                                         $29     
         47        ASSIGN                                                   !4, $29
   22    48        INIT_FCALL                                               'sprintf'
   23    49        SEND_VAL                                                 '%25s-%25s-%25s-%25s-%25s'
   24    50        INIT_FCALL                                               'substr'
         51        SEND_VAR                                                 !4
         52        SEND_VAL                                                 0
         53        SEND_VAL                                                 8
         54        DO_ICALL                                         $31     
         55        SEND_VAR                                                 $31
   25    56        INIT_FCALL                                               'substr'
         57        SEND_VAR                                                 !4
         58        SEND_VAL                                                 8
         59        SEND_VAL                                                 4
         60        DO_ICALL                                         $32     
         61        SEND_VAR                                                 $32
   26    62        INIT_FCALL                                               'substr'
         63        SEND_VAR                                                 !4
         64        SEND_VAL                                                 12
         65        SEND_VAL                                                 4
         66        DO_ICALL                                         $33     
         67        SEND_VAR                                                 $33
   27    68        INIT_FCALL                                               'substr'
         69        SEND_VAR                                                 !4
         70        SEND_VAL                                                 16
         71        SEND_VAL                                                 4
         72        DO_ICALL                                         $34     
         73        SEND_VAR                                                 $34
   28    74        INIT_FCALL                                               'substr'
         75        SEND_VAR                                                 !4
         76        SEND_VAL                                                 20
         77        DO_ICALL                                         $35     
         78        SEND_VAR                                                 $35
   22    79        DO_ICALL                                         $36     
   28    80        VERIFY_RETURN_TYPE                                       $36
         81      > RETURN                                                   $36
   30    82*       VERIFY_RETURN_TYPE                                       
         83*     > RETURN                                                   null

End of function uuid7

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.87 ms | 1019 KiB | 22 Q