php

php生成短网址

      function base62($x){  
$show = '';
while($x>0){
$s = $x % 62;
if ($s > 35){
$s = chr($s + 61);
}else if ($s > 5 && $S<=35){
$s = chr($s + 55);
}
$show .= $s;
$x = floor($x/62);
}
return $show;
}

function url_short($url){
$url = crc32($url);
$result = sprintf("%u",$url);
return base62($result);
}

echo ("新网址:".url_short($_POST]'>".url_short($_POST['url'])."");

0 个评论

要回复文章请先登录注册