How to correctly implement PHP to generate a unique identifier _ PHP Tutorial

Source: Internet
Author: User
Correctly implement PHP to generate a unique identifier. Today, we will introduce in detail the sample code for generating a unique identifier in PHP :? Generate the unique identifier sha1 () function. the security hash algorithm (SHA1) functioncreate_uniq is related

Sample code for generating a unique identifier in PHP:

  1. <?
  2. // Generate a unique identifier
  3. // Sha1 () function, "security hash algorithm (SHA1 )"
  4. Function create_unique (){
  5. $ Data = $ _ SERVER ['http _ USER_AGENT ']. $ _ SERVER ['remote _ ADDR']
  6. . Time (). rand ();
  7. Return sha1 ($ data );
  8. // Return md5 (time (). $ data );
  9. // Return $ data;
  10. }
  11. ?>

Function description and example for generating unique identifiers in PHP

 
 
  1. < ?
  2. $newhash = create_unique();
  3. echo $newhash;
  4. ?>


Example code for generating unique identifiers in login PHP :? // Generate the unique identifier // sha1 () function, security hash algorithm (SHA1) functioncreate_uniq...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.