Welcome to WebmasterWorld Guest from 18.104.22.168 , register , free tools , login , search , pro membership , help , library , announcements , recent posts , open posts Become a Pro Member
Present php in CSS Basic but . . . Wonderstuff
If I want to present the outcome of some basic php within my main css page, how do I get it to work?
The basic php which works (without any CSS):
$currentdate = getdate(time()); echo "© Mysite ".$currentdate["year"]; ?>
The basic php contained in CSS:
<? $currentdate = getdate(time()); echo "© Mysite ".$currentdate["year"]; ?> </div>
Or do I need to include a purpose built css.inc file within the php - doh!
Thanks. . . .
You may handle it as your example is set or keep your PHP file in an includes dir and do an <? include"includes/file.php"; ?>
you need also to verify in your php.ini that your short tags is "on"
if not this <? .. script?> will generate an error
You are not telling us what is your file extension
if your file is not a "dot"PHP then you need to set your httpd.conf to parse php within html
if this is getting to be a PHP thread you should ask the CSS mod to move your thread to PHP
Have fun :)
i think you're getting confused.
consider that the php code generates html that is sent to the browser, the css will act on the html code.
so in your case, something like this will be sent to the browser:
<div id="copyright"> © Mysite 2007 </div>
the fact that you created the html server side using php is completely irrelevant, assuming that you have set an id named copyright in your style sheet or in the head of the page it will render the style correctly.
To add to what topr8 said, when writing a style sheet for html pages generated by php you need to anticipate what style you may need. Then, when your php generates the html, include the appropriate ids and classes. Wonderstuff
Gentlemen thanks for you help. You're an inspiration.
The solution was pretty straightforward. I should have asked 'how to parse php via a dot html page.' The solution is to write:
RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html
into my dot htaccess file.
Thanks again for your help.