php生成短网址 仿微博短网址生成代码

WBOY
Release: 2016-07-25 08:54:47
Original
898 people have browsed it
  1. urlShort-php生成短网址_bbs.it-home.org_脚本学堂提供
复制代码

2,生成php短网址的代码。

  1. header("Content-Type:text/html;charset=UTF-8");
  2. function base62($x){
  3. $show = '';
  4. while($x>0){
  5. $s = $x % 62;
  6. if ($s > 35){
  7. $s = chr($s + 61);
  8. }else if ($s > 5 && $S $s = chr($s + 55);
  9. }
  10. $show .= $s;
  11. $x = floor($x/62);
  12. }
  13. return $show;
  14. }
  15. function url_short($url){
  16. $url = crc32($url);
  17. $result = sprintf("%u",$url);
  18. return base62($result);
  19. }
  20. echo ("生成的短网址为:".url_short($_POST['url'])."");
复制代码


source:php.cn
Statement of this Website
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 [email protected]
Latest Issues
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!