Share a PHP short URL generation code.
Copy code The code is as follows:
urlShort header("Content-Type:text/html;charset=UTF-8");
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);
} www.jbxue.com
$show .= $s;
$x = floor( $x/62);
}
return $show;
}
//Generate short URL
function url_short($url){
$url = crc32($url) ;
$result = sprintf("%u",$url);
return base62($result);
}
echo ("Generate short URL:
".url_short($_POST['url'])."");
http://www.bkjia.com/PHPjc/766109.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/766109.htmlTechArticleShare a php short URL generation code. Copy the code as follows: !DOCTYPE html html lang="en" head meta charset="utf-8" / titleurlShort/title /head body form action="urlShort.p...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn