PHP生成短连接的方法.md

PHP生成短连接的方法

直接贴上方法,函数可以查看手册。


<?php
/** 生成短网址 
 * @param  String $url 原网址 
 * @return String 
 */  
function dwz($url){  
    $code=floatval(sprintf('%u', crc32($url)));  
    $surl='';  
    while($code){  
      $mod=fmod($code, 62);  
      if($mod>9 && $mod<35){  
        $mod=chr($mod + 61);  
      }  
      $surl .= $mod;  
      $code = floor($code/62);  
    }  
    return $surl;  
}  

//test
echo dwz('http://www.zyall.com');

相关文章:

  • 2021-07-07
  • 2021-11-25
  • 2021-06-14
  • 2021-11-11
  • 2021-11-27
  • 2021-12-12
  • 2022-12-23
  • 2021-12-30
猜你喜欢
  • 2021-05-21
  • 2021-07-27
  • 2021-12-28
  • 2021-12-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案