Banner Program _php Foundation

Source: Internet
Author: User
<?php
/* banner.php
This PHP3 scrolling program is designed by Anton Olsen (aolsen@graphweb.com), you can freely modify and use this program, and freely spread it, if you have a more important change to it, please write an e-mail.

In this program, the author tries to implement this function in a number of different ways, but the image function in PHP does not display the animated GIF image format and the operation of this format (e.g. fopen, Fpassthru, and Fclose). The author uses the PassThru method to implement it, although this is not the best approach, but it can be more quickly than other methods to display the advertising bar.

In this program, we assume that:
1, you already have a directory that holds all the advertising pictures.
2, all the advertising pictures are in GIF format.
3. All GIF images begin with banner.
3, in this directory there is no other than advertising pictures of the file.

Install this program:
1, put this program and all the advertising pictures (*. GIF) into a directory.
2, put the following HTML code on your Web page:
<a href= "wherever.you.want.com" >

</a>


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 picture. */
Header ("Pragma:no-cache");
Header ("Expires:monday 01-jan-80 12:00:00 GMT");
Header ("Content-type:image/gif");
PassThru ("Cat $array [$r]");

?>

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.