PHP创建桌面快捷方式实例

时间:2023-03-09 04:16:18
PHP创建桌面快捷方式实例

要利用php创建桌面快捷方式我们需要借助于header,InternetShortcut及一些我看不懂的代码。

方法:新建一个php文件,然后把下面的代码扔进去,保存为比如shortcut.php,放在网站跟目录,代码如下:

$shortCut = "[InternetShortcut]
URL=http://www.baidu.com
IDList=
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,2
";
Header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=baidu.url;");
echo $shortCut;

实例:

  header("Content-type: text/html; charset=utf-8");
  $url = 'http://php.net/manual/zh/function.get-meta-tags.php';
  $metas = get_meta_tags($url);
  $kws_arr = array_filter(array_map('trim', explode(',',$metas['keywords'])));
  $filename = empty($kws_arr)?'收藏':$kws_arr[0];
  //print_r($metas);
  $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;