Banner project_php tutorial

Source: Internet
Author: User
Banner Program .? Php * banner. php this PHP3 rolling program is designed by mongoolsen (aolsen@graphweb.com), you can freely modify and use this program, and freely spread it if you are on it /* Banner. php
This PHP3 rolling program is designed by Anton Olsen (aolsen@graphweb.com), you can freely modify and use this program, and freely spread it, if you have made important changes to it, please write an e-mail for all your work.

In this program, the author tries to implement this function in a variety of different ways, but the image function in PHP cannot display the GIF image format of the animation and the operations in this format (such as: fopen, fpassthru, and fclose ). The author has implemented it through the passthru method. Although this is not the best method, it can display ad strips more quickly than other methods.

In this program, we assume that:
1. you already have a directory for storing all advertisement images.
2. All advertisement images are in GIF format.
3. all GIF images start with a banner.
3. there are no other files except advertisement images in this directory.

Install this program:
1. put this program and all advertisement images (*. GIF) in a directory.
2. Place the following HTML code on your WEB page:





4/14/2000 Mouse Chen (litmouse@km169.net) Translate it to Chinese
*/

/* Random ($ max integer)
Returns a random number from 0 to $ MAX-1;
*/
Function random ($ max)
{
$ X = rand ();
$ Y = getrandmax ();

$ R = $ x/$ y * ($ max-1 );

$ R = round ($ r ++ );
Return $ r;
}

/* Read the directory and read all the "banner *" files into an array ;*/
$ I = 0;
$ D = dir (".");
While ($ entry = $ d-> read ())
If (substr ($ entry, 0, 6) = "banner ")
$ Array [$ I ++] = $ entry;
$ D-> close ();


/* Select a random number */
$ R = random ($ I );

/* Send a no-cache and gif file header and output the image. */
Header ("Pragma: no-cache ");
Header ("Expires: Monday 01-Jan-80 12:00:00 GMT ");
Header ("Content-type: image/gif ");
Passthru ("cat $ array [$ r]");

?>

Http://www.bkjia.com/PHPjc/316881.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/316881.htmlTechArticle? Php/* banner. php this PHP3 rolling program is designed by Anton Olsen (aolsen@graphweb.com), you can freely modify and use this program, and freely spread it if you're on it...

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.