4
我試圖創建一個變量背景,圖像根據一天中的時間變化。我用這個代碼工作,但是我在某個地方做了一些事情,並沒有注意到這個功能已經被破壞了。有人可以向我解釋爲什麼這不起作用嗎?在PHP中嵌入PHP
<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>
爲什麼在
之外使用'