Create random background image for your website

Edit & save the following code into background.php and upload it to the same directory as your background images

Call the script from within your html / php or css as you would any standard image eg. (‘images/background.php’) instead of (‘images/background.jpg’)

<?php
// Created by the|ScUnStEr
// R-WBIC - Random website backgound image changer
// Replace *.jpg with the names of your actual images
// Copy this php file into the same directory as your images
// Link to this php file in your html, php or css script
// Use relative directory or full URL links to this script
// Provided as is, no warranty implied or given!
// May work, may not, use it, don't use it!
// Modify & Enjoy!
$img_array = array('background.jpg', 'background1.jpg', 'background2.jpg');
$img_rnd = rand(0, sizeof($img_array) - 1);
header('Content-type: image/jpg');
header('Content-Disposition: filename=' . $img_array[$img_rnd]);
readfile($img_array[$img_rnd]);
?>

Print Friendly, PDF & Email

More Like This


Categories


CSS Tips Web Design
  • Post a comment