Php string shortening solution

Source: Internet
Author: User
Php string shortening requirement $ str = 'topics/new? Forum_id = php'; echo & nbsp; signed URL ($ str) & nbsp; // & nbsp; output: js4d8x5decho & nbsp; unformatted URL ('js4d8x5d ') & nbsp; php string shortening
Requirement

$ Str = 'topics/new? Forum_id = php ';

Echo response URL ($ str) // output: js4d8x5d

Echo unformatted URL ('js4d8x5d ') // restores the string output: topics/new? Forum_id = PHP


Evaluate the functions of signed URL and unsigned URL
------ Solution --------------------
No encoding rules are provided. how do I write a program?
------ Solution --------------------
Short link?
Hash Function + hash conflict solution

Sina's short url seems to be the correspondence between the url stored on the server and the ID number. Not studied
------ Solution --------------------
The computation only results in limited space for compression.
Assuming that the original string does not contain Chinese characters, the 96-0000000 format can be used.
But it can only be reduced by 1/8.

Therefore, short URLs are implemented by using the lookup table method, and only table item indexes are provided.

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.