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( '%s-%04d-%04d-%04d-%04d%04d%04d', time(), $x($c), $x($c), $x($c), $x($c), $x($c), $x($c), $x($c) ); } $uuids = array(); for ($i = 0; $i < 1000; $i++) { $uuids[] = uuid(); } if (count(array_unique($uuids)) != count($uuids)) { echo 'DUPLICATE'; } else { echo 'No duplicate'; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 3
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 3
Branch analysis from position: 10
Branch analysis from position: 3
filename:       /in/Xh12f
function name:  (null)
number of ops:  21
compiled vars:  !0 = $uuids, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   ASSIGN                                                   !0, <array>
   15     1        ASSIGN                                                   !1, 0
          2      > JMP                                                      ->8
   16     3    >   INIT_FCALL                                               'uuid'
          4        DO_FCALL                                      0  $5      
          5        ASSIGN_DIM                                               !0
          6        OP_DATA                                                  $5
   15     7        PRE_INC                                                  !1
          8    >   IS_SMALLER                                               !1, 1000
          9      > JMPNZ                                                    ~7, ->3
   19    10    >   INIT_FCALL                                               'array_unique'
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $8      
         13        COUNT                                            ~9      $8
         14        COUNT                                            ~10     !0
         15        IS_NOT_EQUAL                                             ~9, ~10
         16      > JMPZ                                                     ~11, ->19
   20    17    >   ECHO                                                     'DUPLICATE'
         18      > JMP                                                      ->20
   22    19    >   ECHO                                                     'No+duplicate'
   23    20    > > RETURN                                                   1

Function uuid:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Xh12f
function name:  uuid
number of ops:  39
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%2FXh12f%3A4%240'
          2        ASSIGN                                                   !1, ~2
    8     3        INIT_FCALL                                               'sprintf'
    9     4        SEND_VAL                                                 '%25s-%2504d-%2504d-%2504d-%2504d%2504d%2504d'
   10     5        INIT_FCALL                                               'time'
          6        DO_ICALL                                         $4      
          7        SEND_VAR                                                 $4
          8        INIT_DYNAMIC_CALL                                        !1
          9        SEND_VAR_EX                                              !0
         10        DO_FCALL                                      0  $5      
         11        SEND_VAR                                                 $5
         12        INIT_DYNAMIC_CALL                                        !1
         13        SEND_VAR_EX                                              !0
         14        DO_FCALL                                      0  $6      
         15        SEND_VAR                                                 $6
         16        INIT_DYNAMIC_CALL                                        !1
         17        SEND_VAR_EX                                              !0
         18        DO_FCALL                                      0  $7      
         19        SEND_VAR                                                 $7
         20        INIT_DYNAMIC_CALL                                        !1
         21        SEND_VAR_EX                                              !0
         22        DO_FCALL                                      0  $8      
         23        SEND_VAR                                                 $8
         24        INIT_DYNAMIC_CALL                                        !1
         25        SEND_VAR_EX                                              !0
         26        DO_FCALL                                      0  $9      
         27        SEND_VAR                                                 $9
         28        INIT_DYNAMIC_CALL                                        !1
         29        SEND_VAR_EX                                              !0
         30        DO_FCALL                                      0  $10     
         31        SEND_VAR                                                 $10
         32        INIT_DYNAMIC_CALL                                        !1
         33        SEND_VAR_EX                                              !0
         34        DO_FCALL                                      0  $11     
         35        SEND_VAR                                                 $11
         36        DO_ICALL                                         $12     
         37      > RETURN                                                   $12
   12    38*     > RETURN                                                   null

End of function uuid

Function %00%7Bclosure%7D%2Fin%2FXh12f%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/Xh12f
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%2FXh12f%3A4%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.63 ms | 1406 KiB | 24 Q