Embedding PHP in CSS

nutradiction

New Member
I'm trying to create a variable background, where the image changes based on the time of day. This code I have USED to work, but I did something somewhere along the line and didn't notice that the functionality had broken. Can someone explain to me why this doesn't work?\[code\]<html><?php function day() { if ( $hour >= 6 && $hour <= 18 ) { return 1; } else { return 0; } }?><style type="text/css">body{ background-image: url('<?php echo (day() ? 'images/day_sheep.jpg' : 'images/night_sheep.jpg'); ?>'); background-position: 50% 50%; background-repeat: no-repeat; background-color: silver}a {text-decoration:none;}a:link {color:#ff0000;}a:visited {color:#0000FF;}a:hover {text-decoration:underline;}</style></html>\[/code\]
 
Back
Top