PHP generated short URLs of 3 methods code instances, PHP generated 3 instances _php tutorial

Source: Internet
Author: User

PHP generates a short URL of 3 ways to code instances, PHP generated 3 instances of


Short URL service, may be a lot of friends are no longer unfamiliar, now most of the microblogging, mobile email reminders and other places already have a lot of application patterns, and occupy a certain market. It is estimated that many friends are using it now. After looking at Sina's short connection service, we found that there are 6 main strings.

Too many algorithmic things, there is no need to explore too much, the main or implementation, the following is the code of three ways:

<?php//Pure random generation method function random ($length, $pool = ') {$random = ';       if (empty ($pool)) {$pool = ' abcdefghkmnpqrstuvwxyz ';     $pool. = ' 23456789 ';      } srand (Double) microtime () *1000000);     for ($i = 0; $i < $length; $i + +) {$random. = substr ($pool, (rand ()% (strlen ($pool))), 1);   } return $random;   } $a =random (6);p rint_r ($a); Enumeration Generation method function Shorturl ($input) {$base = 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. = $base 32[$val];   $int = $int >> 5;  } $output [] = $out; } return $output;   } $a =shorturl ("http://www.bkjia.com");p Rint_r ($a);//62-bit generation method function Base62 ($x) {$show = ';  while ($x > 0) {$s = $x% 62;        if ($s >) {$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 the PHP Code auto-generation tool? 》

Hkvstore Phpmaker v4.1.0.2 English official version (PHP Code auto-generation tool)

Related website:
www.hkvstore.com/phpmaker/

Installation Serial Number:
The serial number generator is placed in the keygen clamp

Crack Description:

Chinese Culture Description:

Content Description:

PHP code generation Tool, a MySQL-based database that runs on a Windows platform, automatically generates PHP scripts
of software. Using the generated PHP code, you can browse, modify, and check the database records through the Web page.
queries, additions, and deletions. With it you can get the full PHP code in just a few steps. Generate code that's clear and understandable,
It is convenient for developers to develop on the basis of two times. Contains the keygen.

English Description:

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

XYZ STUDIO strongly recommended!!! Must let you return to the ticket price, the guarantee is not wrong.
≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈
XYZCD Studio (31.to/xyz,76.to/xyz) Catalog editing

Finally, there is an old saying that one more time! The XYZ-made catalogue is just to help you try/buy
Application software, if you feel that the software is really helpful to your work, please
It is necessary to buy the original software in order to support the author or publishing company to re-publish the best software!!! For your future post-
Continue to service, you should buy the original software ... Remaining full text >>

PHP generate file code, help to look,

your foreach {} should enclose the contents of the following
correct
$con =array (Array (' News title ', ' news content '), Array (' News title 2 ', ' news content 2 ');

foreach ($con as $id + $val) {
$title = $val [0];
$content = $val [1];
$path = $id. HTM ';
$fp =fopen ("tmp.htm", "R"),//read-only open template
$str =fread ($fp, FileSize ("tmp.htm")),//Read the contents of the template
$str =str_replace ("{ Title} ", $title, $STR);
$str =str_replace ("{content}", $content, $STR);//replace Content
Fclose ($fp);

$handle =fopen ($path, "w"),//write Open News path
Fwrite ($handle, $STR);//write the contents of the previous replacement into the generated HTML file
fclose ($handle);
echo "Build Success";
}
 

http://www.bkjia.com/PHPjc/840755.html www.bkjia.com true http://www.bkjia.com/PHPjc/840755.html techarticle php generated a short URL of 3 methods code instances, PHP generated 3 instances of short Web site services, may be a lot of friends are no longer unfamiliar, now most of the microblogging, mobile email reminders and other places have ...

  • Related Article

    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.