首页 > 资讯列表 > 编程/数据库 >> PHP

php生成短网址示例代码

PHP 2014-12-19 04:18:03 转载来源: 网络整理/侵权必删

本文是一个php生成短网址示例代码,感兴趣的同学参考下。 php生成短网址   <?php  $chars=array("a","b","c","d","e","f","g","h",     "i","j","k","l","m","n","o","p",     "q","r","s","t","u","v","w","x",     &qu

本文是一个php生成网址示例代码,感兴趣的同学参考下。

php生成短网址
 


<?php 
$chars=array("a","b","c","d","e","f","g","h",
    "i","j","k","l","m","n","o","p",
    "q","r","s","t","u","v","w","x",
    "y","z","0","1","2","3","4","5",
    "6","7","8","9","A","B","C","D",
    "E","F","G","H","I","J","K","L",
    "M","N","O","P","Q","R","S","T",
    "U","V","W","X","Y","Z");
$salt="www.joneto.com";
$hash=md5("http://www.sina.com".$salt);
$rs=array();
for($i=0;$i<4;$i++){
 $temp=substr($hash, $i*8,8);
 $temp=base_convert($temp, 16, 10) & base_convert("3fffffff", 16, 10);

 $str="";
 for($j=0;$j<6;$j++){
  $subtemp=$temp & intval(base_convert("3d", 16, 10));
  $str.=$chars[$subtemp];
  $temp=$temp>>5;
 }
 unset($temp);
 $rs[]=$str;
}
print_r($rs);
?>


标签: php 生成 网址 示例 代码


声明:本文内容来源自网络,文字、图片等素材版权属于原作者,平台转载素材出于传递更多信息,文章内容仅供参考与学习,切勿作为商业目的使用。如果侵害了您的合法权益,请您及时与我们联系,我们会在第一时间进行处理!我们尊重版权,也致力于保护版权,站搜网感谢您的分享!

站长搜索

http://www.adminso.com

Copyright @ 2007~2024 All Rights Reserved.

Powered By 站长搜索

打开手机扫描上面的二维码打开手机版


使用手机软件扫描微信二维码

关注我们可获取更多热点资讯

站长搜索目录系统技术支持