/* banner.php
This PHP3 rolling program is designed by Anton Olsen (aolsen@graphweb.com), you are free to modify and use this program, and freely spread it, if you have more important changes to it, please write an e-mail.
In this program, the author attempts to implement this function in many different ways, but the image function in PHP does not show the animated GIF image format and the operation of this format (such as: fopen, Fpassthru, and Fclose). The author uses the PassThru method to implement it, although this is not the best approach, but it can display the banner more quickly than other methods.
In this procedure, we assume that:
1. You already have a directory that stores all of your advertising images.
2, all the advertising images are in GIF format.
3. All GIF images start with banner.
3. There are no other files in this directory except for advertising images.
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:
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]");
?>
The above describes what banner means banner program, including what is the meaning of banner content, I hope that the PHP tutorial interested in a friend helpful.