Showing posts with label generate unique id php. Show all posts
Showing posts with label generate unique id php. Show all posts
Generate unique ID in PHP
Posted by Raj
PHP UniqueID:
Generate unique ID in PHP
A unique ID can be created in PHP using the uniqid () function.
uniqid():Returns the unique identifier, as a string.
Here are some examples:
<?php
//creates a unique id with the 'unique' prefix
$a = uniqid('unique');
echo $a;
echo "<br>";
//creates a longer unique id with the 'unique' prefix
$b = uniqid ('unique', true);
echo $b;
echo "<br>";
//creates a unique ID with a random number as a prefix
$c = uniqid (rand (),true);
echo $c;
echo "<br>";
//this md5 encrypts the username from above
$md5c = md5($c);
echo $md5c;
?>
Generate unique ID in PHP
A unique ID can be created in PHP using the uniqid () function.
uniqid():Returns the unique identifier, as a string.
Here are some examples:
<?php
//creates a unique id with the 'unique' prefix
$a = uniqid('unique');
echo $a;
echo "<br>";
//creates a longer unique id with the 'unique' prefix
$b = uniqid ('unique', true);
echo $b;
echo "<br>";
//creates a unique ID with a random number as a prefix
$c = uniqid (rand (),true);
echo $c;
echo "<br>";
//this md5 encrypts the username from above
$md5c = md5($c);
echo $md5c;
?>