Orionsbelter Posted December 1, 2009 Share Posted December 1, 2009 Is there any way to use PHP in a CSS file?, or to use a database with a CSS file for example if i want to save the name of a color I.E blue in a database field then print it into a CSS file so i can change this easily when ever i want. Thank you for looking. Quote Link to comment https://forums.phpfreaks.com/topic/183614-is-there-any-way-to-use-php-in-css-files/ Share on other sites More sharing options...
JustLikeIcarus Posted December 1, 2009 Share Posted December 1, 2009 Yeah just have a php file that ouputs css and use it instead of the .css file. Make sure your sending the right header. Quote Link to comment https://forums.phpfreaks.com/topic/183614-is-there-any-way-to-use-php-in-css-files/#findComment-969126 Share on other sites More sharing options...
Orionsbelter Posted December 1, 2009 Author Share Posted December 1, 2009 Could you show an example please. Quote Link to comment https://forums.phpfreaks.com/topic/183614-is-there-any-way-to-use-php-in-css-files/#findComment-969130 Share on other sites More sharing options...
JustLikeIcarus Posted December 1, 2009 Share Posted December 1, 2009 Well simplest example is for you to just take your current css file and change its extension to .php and add <?php header("Content-type: text/css"); ?> To the beginning of it. Then change the html that calls it reflect the new file name. <link rel="stylesheet" type="text/css" media="screen" href="style.php"> Once youve done that you can add whatever else you want in the new file. Quote Link to comment https://forums.phpfreaks.com/topic/183614-is-there-any-way-to-use-php-in-css-files/#findComment-969136 Share on other sites More sharing options...
Orionsbelter Posted December 1, 2009 Author Share Posted December 1, 2009 ok but how much the PHP work in the current CSS file once i changed in to PHP and add the header? Thank you for the reply. Quote Link to comment https://forums.phpfreaks.com/topic/183614-is-there-any-way-to-use-php-in-css-files/#findComment-969140 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.