Short unique id in php

In PHP, you can use the function uniqid() to generate a short unique ID. It generates a unique ID based on the current time in microseconds, and can be prefixed with a string if desired. For example, to generate a short unique ID, you can use the following code:

<?php

$short_id = uniqid();

or

<?php

$prefix = 'abc_';
$short_id = $prefix.uniqid();

This will generate a unique ID that looks something like this: abc_5f8912b1c1b24

Watch a course Learn object oriented PHP

Additionally, you can use com_create_guid() function to generate unique id in php.

<?php

$guid = com_create_guid();

This will generate a unique id which look like this {3B5F6F80-B248-4E81-9F38-095E6A5D4C6F}