国产精品成人VA在线观看,亚洲日韩在线中文字幕综合,亚洲AV电影天堂男人的天堂,久久人人爽人人爽人人av东京热

News新聞

業(yè)界新聞動態(tài)、技術(shù)前沿
Who are we?

您的位置:首頁      樂道系統(tǒng)FAQ      php生成網(wǎng)頁桌面快捷方式

php生成網(wǎng)頁桌面快捷方式

標簽: 發(fā)布日期:2017-05-05 00:00:00 246

本文將介紹使用PHP生成網(wǎng)頁桌面快捷方式的代碼,并添加圖標及解決不同瀏覽器保存出現(xiàn)的亂碼問題。

我們訪問網(wǎng)站時,如果網(wǎng)站的內(nèi)容很有吸引,一般我們都會使用瀏覽器的收藏夾功能,收藏此網(wǎng)站。

在瀏覽器收藏的網(wǎng)頁,需要打開瀏覽器,再從收藏夾選定訪問。

如果可以在桌面直接進入到網(wǎng)站,這樣可以為用戶訪問提供便利。

我們可以使用php創(chuàng)建網(wǎng)頁的快捷入口文件,保存到用戶桌面,方便用戶快速訪問。

生成代碼如下:

<?php
$filename = '破曉領(lǐng)域.url';
$url = 'http://fdipzone.com/';
$icon = 'http://fdipzone.com/favicon.ico';
createShortCut($filename, $url, $icon);
/**
 * 創(chuàng)建保存為桌面代碼
 * @param String $filename 保存的文件名
 * @param String $url   訪問的連接
 * @param String $icon   圖標路徑
 */
function createShortCut($filename, $url, $icon=''){
  // 創(chuàng)建基本代碼
  $shortCut = "[InternetShortcut]\r\nIDList=[{000214A0-0000-0000-C000-000000000046}]\r\nProp3=19,2\r\n";
  $shortCut .= "URL=".$url."\r\n";
  if($icon){
    $shortCut .= "IconFile=".$icon."";
  }
  header("content-type:application/octet-stream");
  // 獲取用戶瀏覽器
  $user_agent = $_SERVER['HTTP_USER_AGENT'];
  $encode_filename = rawurlencode($filename);
  // 不同瀏覽器使用不同編碼輸出
  if(preg_match("/MSIE/", $user_agent)){
    header('content-disposition:attachment; filename="'.$encode_filename.'"');
  }else if(preg_match("/Firefox/", $user_agent)){
    header("content-disposition:attachment; filename*=\"utf8''".$filename.'"');
  }else{
    header('content-disposition:attachment; filename="'.$filename.'"');
  }
  echo $shortCut;
}
?>