kyleldi Posted October 5, 2007 Share Posted October 5, 2007 This might be a stupid question- but is it possible to put PHP code into a CSS file and receive proper results? I use a header image at the top of all my pages (defined in a CSS file), and I'd like to set it up so it changes on certain days. I know making the image change is possible- but can it be done within a CSS file? Thanks kyleldi Quote Link to comment https://forums.phpfreaks.com/topic/72013-php-in-css/ Share on other sites More sharing options...
BlueSkyIS Posted October 5, 2007 Share Posted October 5, 2007 i would use various CSS files and change which one i include() in the header. attempting to execute PHP within a .css file would not be the best way to go, imo. Quote Link to comment https://forums.phpfreaks.com/topic/72013-php-in-css/#findComment-362798 Share on other sites More sharing options...
kyleldi Posted October 5, 2007 Author Share Posted October 5, 2007 Are there any additional options possibly? I'm just kinda trying to see what i've got for resources to make this possible. I've got a series of headers for each holiday, that change on that given day according to the time on my server. Just a way to keep things unique in my opinion. Thanks for your input- i'm working on mimicing something similar right now with your idea. Quote Link to comment https://forums.phpfreaks.com/topic/72013-php-in-css/#findComment-362805 Share on other sites More sharing options...
eagleweb Posted October 5, 2007 Share Posted October 5, 2007 another option is you caninclude a style.php page instead of css page. Just open a new php page and save as styles.php. copy ALL code from your style.css page onto and now you can use php. I have done it and it works. Quote Link to comment https://forums.phpfreaks.com/topic/72013-php-in-css/#findComment-362808 Share on other sites More sharing options...
kyleldi Posted October 5, 2007 Author Share Posted October 5, 2007 Sweet- that sounds like a more direct approach to what I am trying to do. Thanks! It will read everything according to CSS rules? Quote Link to comment https://forums.phpfreaks.com/topic/72013-php-in-css/#findComment-362811 Share on other sites More sharing options...
BlueSkyIS Posted October 5, 2007 Share Posted October 5, 2007 yep, that works. but all we've done is pulled out PHP from the main page and put it into an include(). We still haven't resolved the dynamic CSS issue. we still have one file which is going to need to call one of several CSS files unless we add processing to change the CSS dynamically, for instance, we could have this in a file called cssinclude.php: <? // Determine values for a_font and some_color up here, then output later: ?> <STYLE> H1 { font-family: <?=$a_font;?>; color: <?=$some_color;?>; } </STYLE> Quote Link to comment https://forums.phpfreaks.com/topic/72013-php-in-css/#findComment-362817 Share on other sites More sharing options...
eagleweb Posted October 5, 2007 Share Posted October 5, 2007 are you just changing images or fonts and colors too? Quote Link to comment https://forums.phpfreaks.com/topic/72013-php-in-css/#findComment-362838 Share on other sites More sharing options...
kyleldi Posted October 5, 2007 Author Share Posted October 5, 2007 Just images, at the moment anyway. Quote Link to comment https://forums.phpfreaks.com/topic/72013-php-in-css/#findComment-362842 Share on other sites More sharing options...
eagleweb Posted October 5, 2007 Share Posted October 5, 2007 BlueSkyIS first idea would work well. Or, why not just write php code in the header and include the header page at the top of each page. That would be easiest. Quote Link to comment https://forums.phpfreaks.com/topic/72013-php-in-css/#findComment-362866 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.