Mason
Mason

Reputation: 81

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, but i dont want to write 150 pages for all the colors for the whole site, is there an easier way to do this?

Upvotes: 0

Views: 255

Answers (2)

mpj
mpj

Reputation: 5367

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}

Upvotes: 2

KomarSerjio
KomarSerjio

Reputation: 2911

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

Upvotes: 0

Related Questions