uniqid() function in PHP

The uniqid() function generates a unique ID based on the current time in microseconds.

Syntax

uniqid(prefix, more_entropy)

Parameters

  • prefix − The prefix to the unique ID.

  • more_entropy − The more entropy at the end of the return value.

Return

The uniqid() function returns unique identifiers as string.

Example

<?php
   echo uniqid();
?>

Output

The following is the output.

5bfd5bd045faa
Updated on: 2026-03-11T22:50:43+05:30

377 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements