Home > php教程 > php手册 > body text

如何正确实现PHP生成唯一标识符

WBOY
Release: 2016-06-13 11:10:51
Original
1713 people have browsed it

我们今天要为大家详细介绍的是有关

PHP生成唯一标识符代码示例:

  1.  ?  
  2. //生成唯一标识符   
  3. //sha1()函数, "安全散列算法(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生成唯一标识符函数描述及例子

<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>
</li>
<li class="alt"><span> </span></li>
</ol>
Copy after login


source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template