Need to generate style sheets dynamically with PHP to keep presentaion logic together or create environment aware style sheets with PHP and JavaScript? This tutorial shows you how!
When I first saw an article illustrating PHP style sheets I laughed to myself. I'm not sure why the idea struck me as odd... after all, PHP has been used to generate all sorts of dynamic documents such as images, PDFs and spreadsheets. PHP is certainly not limited to generating HTML output!
The more I thought about it the more I began to see some of the benefits of generating style sheets with PHP. It can help keep related styles together in one document as opposed to having separate files for various browsers and JavaScript can be used on the client side to pass values back to the server so a custom style sheet can be created.
In this tutorial I'll explain each of these options.