程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> php生成短網址示例

php生成短網址示例

編輯:關於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);
?>

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved