Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Digital Web Magazine:
Dynamic CSS with PHP
May 04, 2005 @ 12:45:40

In this new article from Digital Web Magazine today, they seek to show you an easy way to use PHP to dynamically generate the CSS on your site - in this case changing some coloring on the site based on a variable in the GET string.

One reason for this explosive growth is that PHP is free and open source. It's also a relatively easy language to learn and the de facto standard for developers creating dynamic Web pages. But it is also perfectly suited for deploying CSS and many other Web technologies.

To demonstrate this technique I will design a mock up of a basic site layout using CSS. It will include a masthead, menu and content area. I will then assign three color schemes using PHP for the background and foreground colors of each element in the layout and show you how you can easily switch between each one or add new schemes - all from one script. I'll conclude the article by suggesting ways you can extend or improve on these ideas for your own site.

The basic idea is a pretty simple one - define the files with the CSS information in it, link them as alternate stylesheets and use the $_GET['scheme'] variable to switch between them.

tagged:

Link:


Trending Topics: