Rotating Advertisement Script in PHP


With this PHP script, you'll rotate ads in random order on your website. This ad rotation script can handle banner advertisements, text-based ads, etc. Reload this page to see this banner change:
Webmasters Make $$$
Webmasters Make $$$
First, create a file with a name like adverts.php and have this at the top: For each of your advertisements, you'll first write out the ad's code, and then increase the banner counter, like this: For the example below, let's do a 3-banner rotation. Note that every " in your ad code needs to be "escaped" with a slash mark in front of the quote mark, like this: \" Next, we get the total number of ads, and if there are more than one, we'll randomly pick one of them. (If less than one, we automatically pick the first advertisement. This may seem like a stupid feature for a random advert generator, but it could happen if you drop non-performing affiliates or if paid-inclusion ads expire.) That's the end of the adverts.php file.
Now, your webpage showing the ad first needs to include this script, then show the ad, like this:
That's all!

Troubleshooting tips for the Ad Rotation PHP Script

»» More php scripts
Webmasters Make $$$
Webmasters Make $$$