php生成微博短网址的算法

字体大小: 中小 标准 ->行高大小: 标准

<?php 

02 function code62($x) { 

03     $show = ''; 

04     while($x > 0) { 

05         $s = $x % 62; 

06         if ($s > 35) { 

07             $s = chr($s+61); 

08         } elseif ($s > 9 && $s <=35) { 

09             $s = chr($s + 55); 

10         } 

11         $show .= $s; 

12         $x = floor($x/62); 

13     } 

14     return $show; 

15 } 

16     

17 function shorturl($url) { 

18     $url = crc32($url); 

19     $result = sprintf("%u", $url); 

20     //return $url; 

21     //return $result; 

22     return code62($result); 

23 } 

24   

25 echo shorturl("此处为网址"); 

26 ?>

此文章由 http://www.ositren.com 收集整理 ,地址为: http://www.ositren.com/htmls/29896.html