Home > Article > Backend Development > PHP creates desktop shortcut instance, php shortcut instance_PHP tutorial
To use php to create desktop shortcut we need to use header, InternetShortcut and some codes that I can’t understand.
Method: Create a new php file, then throw the following code into it, save it as shortcut.php, for example, and place it on the website and directory. The code is as follows:
<span>$shortCut</span> = "<span>[InternetShortcut] URL=http://www.baidu.com IDList= [{000214A0-0000-0000-C000-000000000046}] Prop3=19,2 </span>"<span>; </span><span>Header</span>("Content-type: application/octet-stream"<span>); </span><span>header</span>("Content-Disposition: attachment; filename=baidu.url;"<span>); </span><span>echo</span> <span>$shortCut</span>;
You have to write a separate page to create the shortcut. I estimate that you have already output the content on the page before, so I am making a mistake
a.php
------ ----------------------------
$url = $_GET['url'];
$filename = urldecode( $_GET['name']);
$filename = iconv('utf-8','GBk',$filename);//Character set conversion
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;
Make a hyperlink when generating
2e0ad1143a32a48ba2f2bae4be1d6c66shortcut9e32f8f94052860b45a49575b3ca74c8