Use PHP to convert URLs to short URLs-php Tutorial

Source: Internet
Author: User
Using PHP to convert URLs to Short URLs (Short URLs) is a Short URL. Today in Web 2.0, we have to say that this is a trend. There are already many similar services. with short URLs, you can replace the original lengthy URLs with short URLs, so that users can easily share links.

The following is an algorithm for short URL conversion using PHP. the code is as follows:

 > 5;} $ short_url_list [] = $ short_url;} return $ short_url_list;} $ url = "http://www.sunbloger.com/"; $ short = response url: encode ($ url ); print_r ($ short);?>

We usually use the first group in the four groups of URLs.

Note that this algorithm is irreversible. Therefore, the common practice is to store the short URL and the corresponding original URL to the database, retrieve the matched original URL from the database and jump to the URL through 301 or header.

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.