php生成短网址

function SuoUrl($url='')
{
    $urlcode =$this->shorturl($url);
}
function shorturl($url){
    $url=crc32($url);
    $result=sprintf("%u",$url);
    $res = $this->code62($result);
    return $res;
}
function code62($result){
    $show='';
    while($x>0){
        $s=$x % 62;
        if ($s>35){
            $s=chr($s+61);
        }elseif($s>9&&$s<=35){
            $s=chr($s+55);
        }
        $show.=$s;
        $x=floor($x/62);
    }
    return $show;
}

猜你喜欢

转载自blog.csdn.net/qd55815634/article/details/79130478