php生成短网址仿微博短网址生成代码
时间:2021-07-01 10:21:17
帮助过:15人阅读
-
-
-
-
- urlShort-php生成短网址_bbs.it-home.org_脚本学堂提供
-
-
-
-
-
-
2,生成php短网址的代码。
- 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);
- }
- $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'])."");
|