Home  >  Article  >  Backend Development  >  How to correctly implement PHP to generate unique identifiers_PHP Tutorial

How to correctly implement PHP to generate unique identifiers_PHP Tutorial

WBOY
WBOYOriginal
2016-07-15 13:33:551148browse

What we want to introduce to you in detail today is the code example of

PHP generating unique identifier:

  1. < ?
  2. //Generate unique identifier
  3. //sha1() function, "Secure 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. ?>

PHP generate unique identifier function description and examples

<ol class="dp-xml">
<li class="alt"><span><span class="tag"><</span><span> ?   </span></span></li><li><span>$</span><span class="attribute">newhash</span><span> = </span><span class="attribute-value">create_unique</span><span>();   </span></li><li class="alt"><span>echo $newhash;   </span></li><li><span class="tag">?></span><span>   </span></span></li>
<li class="alt"><span> </span></li>
</ol>


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/446019.htmlTechArticleWhat we want to introduce to you in detail today is the code example for generating unique identifiers in PHP: ? //Generate unique identifiers Symbol //sha1() function, secure hash algorithm (SHA1) functioncreate_uniq...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn