How to call PHP in your CSS: specifically changing header imgs
-
Question: How do i integrate PHP into my CSS?
Why: I want to have a random header image, and the 2 plugins i grabbed won’t work.
———————————————–
So far:
in my style.css i want to edit this entry:
———————————————–
#headerimg {
background: url(“images/header.jpg”);
}
———————————————–
And i have this php to grab random images (named 1.jpg, 2.jpg) from a folder.
———————————————–
<?php// Change this to the total number of images in the folder
$total = “2”;// Change to the type of files to use eg. .jpg or .gif
$file_type = “.jpg”;//Starting the randomizing
$start = “1”;
$random = mt_rand($start, $total);
$image_name = $random . $file_type;
echo $image_name;
?>
———————————————–
The images and the php will be in the same folder.So how do i integrate my PHP file into my CSS? Just naming it in the url tag won’t work.
any ideas?
- The topic ‘How to call PHP in your CSS: specifically changing header imgs’ is closed to new replies.