开发者

How to set a color for all pages in php?

开发者 https://www.devze.com 2023-02-11 19:12 出处:网络
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:

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

精彩评论

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