Do something like that
<?php
$class = ($page == 'home') ? 'class="bg-red"' : '';
<body $class>
</body>
?>
And in your style :
.bg-red {
background-color:red;
}
solved How do I make background colour of webpages change dynamically with PHP? [closed]