亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

php創(chuàng)建桌面快捷方式實(shí)現(xiàn)方法

 更新時(shí)間:2022年08月07日 22:46:02   投稿:lijiao  
這篇文章主要介紹了php創(chuàng)建桌面快捷方式實(shí)現(xiàn)方法,需要的朋友可以參考下

第一種情況:php生成網(wǎng)頁(yè)桌面快捷方式

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

我們?cè)L問(wèn)網(wǎng)站時(shí),如果網(wǎng)站的內(nèi)容很有吸引,一般我們都會(huì)使用瀏覽器的收藏夾功能,收藏此網(wǎng)站。
在瀏覽器收藏的網(wǎng)頁(yè),需要打開(kāi)瀏覽器,再?gòu)氖詹貖A選定訪(fǎng)問(wèn)。

如果可以在桌面直接進(jìn)入到網(wǎng)站,這樣可以為用戶(hù)訪(fǎng)問(wèn)提供便利。
我們可以使用php創(chuàng)建網(wǎng)頁(yè)的快捷入口文件,保存到用戶(hù)桌面,方便用戶(hù)快速訪(fǎng)問(wèn)。

生成代碼如下:

<?php
$filename = '腳本之家.url';
$url = 'http://chabaoo.cn/';
$icon = 'http://chabaoo.cn/favicon.ico';

createShortCut($filename, $url, $icon);

/**
 * 創(chuàng)建保存為桌面代碼
 * @param String $filename 保存的文件名
 * @param String $url   訪(fǎng)問(wèn)的連接
 * @param String $icon   圖標(biāo)路徑
 */
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");

  // 獲取用戶(hù)瀏覽器
  $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;

}
?>

下載保存到桌面

保存到桌面

在桌面保存為*.url后,點(diǎn)擊就能自動(dòng)打開(kāi)瀏覽器并訪(fǎng)問(wèn)網(wǎng)站內(nèi)容了。

第二種情況:PHP實(shí)現(xiàn)網(wǎng)站保存快捷桌面方式

<?php
/*
保存shortcut.php訪(fǎng)問(wèn)即可保存桌面
*/
$title="腳本之家";
$Shortcut = "[InternetShortcut]
URL=http://chabaoo.cn
IDList= 
[{000214A0-0000-0000-C000-000000000046}] 
Prop3=19,2";
Header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=".$title.".url;");
echo $Shortcut;
?>

第三種情況:PHP生成網(wǎng)站桌面快捷方式

PHP生成桌面快捷方式就是這么的簡(jiǎn)單,大家生成的時(shí)候改下你要生成的網(wǎng)站即可。

dianji.html代碼:

 <a href="a.php?url=chabaoo.cn&name=腳本之家">生成左面快捷方式</a>

shengcheng.php代碼:

 <?php
//網(wǎng)站生存左面快捷方式---功能 
$url = $_GET['url']; 
$filename = urldecode($_GET['name']); 
$filename = iconv('GBk','utf-8',$filename);//字符集轉(zhuǎn)換(沒(méi)有需要轉(zhuǎn)的就不轉(zhuǎn)) 
if (!$url || !$filename) exit();
$Shortcut = "[InternetShortcut] 
URL={$url}
IDList= 
[{000214A0-0000-0000-C000-000000000046}] 
Prop3=19,2"; 
header("Content-type: application/octet-stream"); 
header("Content-Disposition: attachment; filename={$filename}.url;");
echo $Shortcut; 
?>

希望本文所述對(duì)大家學(xué)習(xí)php程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論