How to Rotate a PHP Background
If you would like to provide a constantly rotating background for your website, you can use PHP code to cycle through a group of images. This will make your site more dynamic and give a reason for visitors to return. This effect can be done by using a PHP rotate script that you can install into your Web hosting server.
Instructions
-
-
1
Download the PHP Random Image Rotation Script (see Resources). Unzip the file. The download should take under a minute.
-
2
Upload the "rotate.php" file into a folder on your Web hosting server. In this same folder, place the images you wish your background to rotate between. These can be images that are .gif, .jpg, .png or any combination of the three.
-
-
3
Enter "rotate.php" in your background style. In your CSS or HTML file, change your code to "background-image:URL('rotate.php')" This will refer your background to the rotate image script.
-
4
Change the "$folder = '.';" command in your "rotate.php" script to indicate which directory to take pictures from. By default, the script will rotate through images in the directory in which your "rotate.php" script is located.
-
1
Tips & Warnings
Use images that are different but still blend in with the overall design of your website.
References
- Photo Credit Comstock/Comstock/Getty Images