Search
 
SCRIPT & CODE EXAMPLE
 

PHP

create guid in php

function guidv4()
{
    if (function_exists('com_create_guid') === true)
        return trim(com_create_guid(), '{}');

    $data = openssl_random_pseudo_bytes(16);
    $data[6] = chr(ord($data[6]) & 0x0f | 0x40); // set version to 0100
    $data[8] = chr(ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to 10
    return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
}
Comment

PHP Function to create GUID

function create_guid() { // Create GUID (Globally Unique Identifier)
        $guid = '';
        $namespace = rand(11111, 99999);
        $uid = uniqid('', true);
        $data = $namespace;
        $data .= $_SERVER['REQUEST_TIME'];
        $data .= $_SERVER['HTTP_USER_AGENT'];
        $data .= $_SERVER['REMOTE_ADDR'];
        $data .= $_SERVER['REMOTE_PORT'];
        $hash = strtoupper(hash('ripemd128', $uid . $guid . md5($data)));
        $guid = substr($hash,  0,  8) . '-' .
                substr($hash,  8,  4) . '-' .
                substr($hash, 12,  4) . '-' .
                substr($hash, 16,  4) . '-' .
                substr($hash, 20, 12);
        return $guid;
    }
Comment

PREVIOUS NEXT
Code Example
Php :: php artisan optimize command 
Php :: unique laravel migration 
Php :: foreach range php 
Php :: undefined variable _session 
Php :: collection laravel Gets the last key of an array 
Php :: php fwrite new line 
Php :: count child products for each parent Product laravel 
Php :: php counting number of chars excluding newlines 
Php :: PHP strrchr — Find the last occurrence of a character in a string 
Php :: php extract email address from string 
Php :: how to check if input is number only in php 
Php :: php get ip by domain 
Php :: fecade Artisan:call laravel 
Php :: acf get sub field 
Php :: php show error 
Php :: cakephp 2 with customize link 
Php :: stream_set_blocking 
Php :: how to add extra days from a date php 
Php :: how to debug in php 
Php :: Deprecated Functionality: stripos() 
Php :: unique sql queries laravel 
Php :: php limit words 
Php :: PHP File Open/Read/Close 
Php :: php check if number starts with 0 
Php :: 500 error php 
Php :: php get all values from associative array 
Php :: return back in laravel 
Php :: laravel public access inserver using htaccess 
Php :: php ini_set timeout 
Php :: fore install debian 10 php 7.3 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =