Skip to content

Instantly share code, notes, and snippets.

@lbp0200
Last active August 29, 2015 14:18
Show Gist options
  • Save lbp0200/013b07efd8332183d834 to your computer and use it in GitHub Desktop.
Save lbp0200/013b07efd8332183d834 to your computer and use it in GitHub Desktop.
get-guid
function guid() {
function s4() {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
}
return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
s4() + '-' + s4() + s4() + s4();
}
<?php
function GUID()
{
if (function_exists('com_create_guid') === true)
{
return trim(com_create_guid(), '{}');
}
return sprintf('%04X%04X-%04X-%04X-%04X-%04X%04X%04X', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment