PHP generates three types of code instances for short URLs, and php generates three types of instances.

Source: Internet
Author: User

PHP generates three types of code instances for short URLs, and php generates three types of instances.

The short URL service may be no longer unfamiliar to many of my friends. Now, there are many application modes in most Weibo, mobile phone email reminders and other places, and they occupy a certain market. It is estimated that many of our friends are using the service now. I have read Sina's short Connection Service and found that there are 6 strings at the end.

There are too many algorithms and there is no need to discuss them too much. The most important thing is implementation. Below are three methods of code:

<? Php // function random ($ length, $ pool = '') {$ random =''; if (empty ($ pool )) {$ pool = 'abcdefghkmnpqrstuvwxy'; $ pool. = '20140901';} srand (double) microtime () * 23456789); for ($ I = 0; $ I <$ length; $ I ++) {$ random. = substr ($ pool, (rand () % (strlen ($ pool), 1);} return $ random;} $ a = random (6 ); print_r ($ a); // function compute URL ($ input) of the enumeration generation method {$ base32 = array ("0", "1", "2", "3 ", "4", "5 "," 6 "," 7 "," 8 "," 9 "," a "," B "," c "," d "," e "," f ", "g", "h", "I", "j", "k", "l", "m", "n", "o", "p ", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z ", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J ", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T ", "U", "V", "W", "X", "Y", "Z"); $ hex = md5 ($ input ); $ hexLen = strlen ($ hex); $ subHexLen = $ hexLen/8; $ output = array (); for ($ I = 0; $ I <$ subHexLen; $ I ++) {$ subHex = substr ($ hex, $ I * 8, 8); $ int = 0x3FFFFFFF & (1 * ('0x '. $ subHex); $ out = ''; for ($ j = 0; $ j <6; $ j ++) {$ val = 0x0000001F & $ int; $ out. = $ base32 [$ val]; $ int = $ int> 5;} $ output [] = $ out;} return $ output ;} $ a = signed URL ("http://www.bkjia.com"); print_r ($ a); // 62-bit function base62 ($ x) {$ show = ''; while ($ x> 0) {$ s = $ x % 62; if ($ s> 35) {$ s = chr ($ s + 61 );} elseif ($ s> 9 & $ S <= 35) {$ s = chr ($ s + 55);} $ show. = $ s; $ x = floor ($ x/62);} return $ show;} function urlShort ($ url) {$ url = crc32 ($ url ); $ result = sprintf ("% u", $ url); return base62 ($ result);} echo urlShort ("http://www.bkjia.com/");?>


Looking for an automatic PHP code generation tool?

Hkvstore PHPMaker v4.1.0.2 official English version (PHP Code Automatic Generation Tool)

Related urls:
Www.hkvstore.com/phpmaker/

Installation No:
Serial number generator placed in the keygen folder

Attack Description:

Description of culture:

Description:

PHP Code Automatic Generation Tool, a PHP script automatically generated based on MYSQL database running on Windows Platform
Software. Using the generated PHP code, you can browse, modify, and query database records on the WEB page.
Query, add, and delete. Using it, you can get the complete PHP code in just a few steps. Clear and easy-to-understand code generation,
This facilitates secondary development by developers. Includes the registration machine.

English description:

PHPMaker is a powerful automation tool that can generate a full set of PHP
Quickly from MySQL database. Using PHPMaker, you can instantly create Web
Sites that allow users to view, edit, search, add and delete records on
Web. PHPMaker is designed for high flexibility, numerous options enable you
To generate PHP applications that best suits your needs. The generated
Codes are clean, straightforward and easy-to-customize. The PHP scripts can
Be run on both Windows or Linux/Unix servers. PHPMaker can save you tons
Time and is suitable for both beginners and experienced develpers alike.

Xyz studio is strongly recommended !!! Make sure you return the fare.

XYZCD Studio (31.to/ xyz, 76.to/ xyz) Directory editing

Finally, I want to emphasize it again! The directory created by XYZ only helps you try/purchase
Application Software. If you think these trial software is really helpful for your work, please
You need to buy the original software to support the author or publishing company to publish the best software !!! For your future
To continue the service, you should purchase the original software... the remaining full text>
 
Php generates file code,

The {} after your foreach should include all the following content.
Which of the following statements is true?
$ Con = array ('news title', 'news content'), array ('news title', 'news content2 '));

Foreach ($ con as $ id => $ val ){
$ Title = $ val [0];
$ Content = $ val [1];
Using pathpattern using id.'.htm ';
$ Fp = fopen ("tmp.htm", "r"); // read-only open Template
$ Str = fread ($ fp, filesize ("tmp.htm"); // read the template content
$ Str = str_replace ("{title}", $ title, $ str );
$ Str = str_replace ("{content}", $ content, $ str); // replace content
Fclose ($ fp );

$ Handle = fopen ($ path, "w"); // The path to open the news in writing mode.
Fwrite ($ handle, $ str); // write the replaced content into the generated HTML file.
Fclose ($ handle );
Echo "generated successfully ";
}

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.