开发者

How to set a color for all pages in php?

How can you set the background colors for all pages inside of a php session? and then recall it on each page? like right now im using:

include('background.php')

but im only using that for the basic pages, i have a whole page setup for other colors to change to开发者_如何学JAVA, but i dont want to write 150 pages for all the colors for the whole site, is there an easier way to do this?


Instead of including a php file, you should try something like this.

Every time you want to modify the background color, add a class to the body.

<?php
  $bodyClass = '';

  if (YOUR CONDITION)
     $bodyClass = 'darkBackground';
?>

<body class="<?php echo $bodyClass; ?>">
...

Then in your CSS file:

body.darkBackground {background-color: black}


I think you should use CSS. It's not the PHP stuff.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜