[PHP] 生成短链接函数
原文地址:http://www.qttc.net/201206105.html
function urlShort($url){ $url= crc32($url); $result= sprintf("%u", $url); $sUrl= ''; while($result>0){ $s= $result%62; if($s>35){ $s= chr($s+61); } elseif($s>9 && $s<=35){ $s= chr($s+ 55); } $sUrl.= $s; $result= floor($result/62); } return $sUrl; } $url = 'http://www.sharefamily.net'; $sUrl = urlShort($url); echo '网址:'.$url."\n\n"; echo '短网址:'.$sUrl."\n\n";