uuid - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of uuid.php

  1. <?php
  2.  
  3.  echo sprintf(
  4.         '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
  5.         // 32 bits for "time_low"
  6.         random_int(0, 65535),
  7.         random_int(0, 65535),
  8.         // 16 bits for "time_mid"
  9.         random_int(0, 65535),
  10.         // 12 bits before the 0100 of (version) 4 for "time_hi_and_version"
  11.         random_int(0, 4095) | 0x4000,
  12.         // 16 bits, 8 bits for "clk_seq_hi_res",
  13.         // 8 bits for "clk_seq_low",
  14.         // two most significant bits holds zero and one for variant DCE1.1
  15.         random_int(0, 0x3fff) | 0x8000,
  16.         // 48 bits for "node"
  17.         random_int(0, 65535),
  18.         random_int(0, 65535),
  19.         random_int(0, 65535)
  20.     );
File Description
  • uuid
  • PHP Code
  • 09 Apr-2021
  • 668 Bytes
You can Share it: