Php desktop shortcuts

Source: Internet
Author: User
Tags learn php programming
This article describes how to create a desktop shortcut in php. First case: Php generate web desktop shortcuts

This section describes how to use php to generate a webpage desktop shortcut code, add icons, and solve the garbled code problem in different browsers.

When we visit a website, if the content of the website is very attractive, we usually use the favorites function of the browser to add this website to favorites.
To add a webpage to the Favorites folder in a browser, open the browser and select it from the Favorites folder.

If you can directly access the website on the desktop, this will facilitate user access.
You can use php to create a shortcut file for a webpage and save it to your desktop for quick access.

The generated code is as follows:

<? Php $ filename = 'Dawn domain. url'; $ url =' http://fdipzone.com/ '; $ Icon =' http://fdipzone.com/ Favicon. ico '; createShortCut ($ filename, $ url, $ icon ); /*** create and save the file name as the desktop code * @ param String $ filename the saved file name * @ param String $ url access connection * @ param String $ icon path */function createShortCut ($ filename, $ url, $ icon = '') {// create basic code $ shortCut = "[InternetShortcut] \ r \ nIDList = [{000214a0-0000-0000-c000-0000000000000046}] \ r \ nProp3 = 19,2 \ r \ n"; $ shortCut. = "URL = ". $ url. "\ r \ n"; if ($ icon) {$ shortCut cut. = "IconFile = ". $ icon. "";} Header ("content-type: application/octet-stream"); // obtain the user's browser $ user_agent =$ _ SERVER ['http _ USER_AGENT ']; $ encode_filename = rawurlencode ($ filename); // different browsers use different encoding to output 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;}?>

Download and save to desktop

Save to desktop

After saving it as *. url on the desktop, click it to automatically open the browser and access the website content.

Case 2:PHP allows you to save your website to a desktop quickly.

<? Php/* save your cut. php access to save the desktop */$ title = ""; $ your cut = "[InternetShortcut] URL = http://www.jb51.netIDList =
[{000214A0-0000-0000-C000-000000000046}] Prop3 = 19,2 "; Header (" Content-type: application/octet-stream "); header (" Content-Disposition: attachment; filename = ". $ title. ". url; "); echo $ Shortcut;?>

Case 3:PHP generates website desktop shortcuts
The PHP desktop shortcut is so simple that you can change the website you want to generate when you generate it.
Dianji.html code:
Generate a left-side shortcut
Shengcheng. php code:

<? Php // saved url on the left of the website --- function $ url =$ _ GET ['URL']; $ filename = urldecode ($ _ GET ['name']); $ filename = iconv ('gbk', 'utf-8', $ filename); // character set conversion (no need to convert) if (! $ Url |! $ Filename) exit (); $ response cut = "[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;?>

I hope this article will help you learn php programming.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.