3v4l.org

run code in 300+ PHP versions simultaneously
<?php function uuid($c = 4) { $x = function($c) { for ($n = ''; strlen($n) < $c + 1; $n = $n.mt_rand()); return substr($n, -$c); }; return sprintf( '%x-%04x-%04x-%04x-%04x%04x%04x', microtime(true) * 10000, $x($c), $x($c), $x($c), $x($c), $x($c), $x($c) ); } $time = microtime(); $uuids = array(); for ($i = 0; $i < 1000; $i++) { $uuids[] = uuid(); } if (count(array_unique($uuids)) != count($uuids)) { echo 'DUPLICATE'; } else { echo 'No duplicate'; print_r($uuids); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 6
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 6
Branch analysis from position: 13
Branch analysis from position: 6
filename:       /in/qWbJB
function name:  (null)
number of ops:  27
compiled vars:  !0 = $time, !1 = $uuids, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   INIT_FCALL                                               'microtime'
          1        DO_ICALL                                         $3      
          2        ASSIGN                                                   !0, $3
   15     3        ASSIGN                                                   !1, <array>
   16     4        ASSIGN                                                   !2, 0
          5      > JMP                                                      ->11
   17     6    >   INIT_FCALL                                               'uuid'
          7        DO_FCALL                                      0  $8      
          8        ASSIGN_DIM                                               !1
          9        OP_DATA                                                  $8
   16    10        PRE_INC                                                  !2
         11    >   IS_SMALLER                                               !2, 1000
         12      > JMPNZ                                                    ~10, ->6
   20    13    >   INIT_FCALL                                               'array_unique'
         14        SEND_VAR                                                 !1
         15        DO_ICALL                                         $11     
         16        COUNT                                            ~12     $11
         17        COUNT                                            ~13     !1
         18        IS_NOT_EQUAL                                             ~12, ~13
         19      > JMPZ                                                     ~14, ->22
   21    20    >   ECHO                                                     'DUPLICATE'
         21      > JMP                                                      ->26
   23    22    >   ECHO                                                     'No+duplicate'
   24    23        INIT_FCALL                                               'print_r'
         24        SEND_VAR                                                 !1
         25        DO_ICALL                                                 
   25    26    > > RETURN                                                   1

Function uuid:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qWbJB
function name:  uuid
number of ops:  37
compiled vars:  !0 = $c, !1 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV_INIT                                        !0      4
    4     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FqWbJB%3A4%240'
          2        ASSIGN                                                   !1, ~2
    8     3        INIT_FCALL                                               'sprintf'
    9     4        SEND_VAL                                                 '%25x-%2504x-%2504x-%2504x-%2504x%2504x%2504x'
   10     5        INIT_FCALL                                               'microtime'
          6        SEND_VAL                                                 <true>
          7        DO_ICALL                                         $4      
          8        MUL                                              ~5      $4, 10000
          9        SEND_VAL                                                 ~5
         10        INIT_DYNAMIC_CALL                                        !1
         11        SEND_VAR_EX                                              !0
         12        DO_FCALL                                      0  $6      
         13        SEND_VAR                                                 $6
         14        INIT_DYNAMIC_CALL                                        !1
         15        SEND_VAR_EX                                              !0
         16        DO_FCALL                                      0  $7      
         17        SEND_VAR                                                 $7
         18        INIT_DYNAMIC_CALL                                        !1
         19        SEND_VAR_EX                                              !0
         20        DO_FCALL                                      0  $8      
         21        SEND_VAR                                                 $8
         22        INIT_DYNAMIC_CALL                                        !1
         23        SEND_VAR_EX                                              !0
         24        DO_FCALL                                      0  $9      
         25        SEND_VAR                                                 $9
         26        INIT_DYNAMIC_CALL                                        !1
         27        SEND_VAR_EX                                              !0
         28        DO_FCALL                                      0  $10     
         29        SEND_VAR                                                 $10
         30        INIT_DYNAMIC_CALL                                        !1
         31        SEND_VAR_EX                                              !0
         32        DO_FCALL                                      0  $11     
         33        SEND_VAR                                                 $11
         34        DO_ICALL                                         $12     
         35      > RETURN                                                   $12
   12    36*     > RETURN                                                   null

End of function uuid

Function %00%7Bclosure%7D%2Fin%2FqWbJB%3A4%240:
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 = 11, Position 2 = 3
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 3
Branch analysis from position: 11
Branch analysis from position: 3
filename:       /in/qWbJB
function name:  {closure}
number of ops:  18
compiled vars:  !0 = $c, !1 = $n
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        ASSIGN                                                   !1, ''
          2      > JMP                                                      ->7
          3    >   INIT_FCALL                                               'mt_rand'
          4        DO_ICALL                                         $3      
          5        CONCAT                                           ~4      !1, $3
          6        ASSIGN                                                   !1, ~4
          7    >   STRLEN                                           ~6      !1
          8        ADD                                              ~7      !0, 1
          9        IS_SMALLER                                               ~6, ~7
         10      > JMPNZ                                                    ~8, ->3
    6    11    >   INIT_FCALL                                               'substr'
         12        SEND_VAR                                                 !1
         13        MUL                                              ~9      !0, -1
         14        SEND_VAL                                                 ~9
         15        DO_ICALL                                         $10     
         16      > RETURN                                                   $10
    7    17*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FqWbJB%3A4%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.41 ms | 1398 KiB | 26 Q