homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / CSS
Forum Library, Charter, Moderators: not2easy

CSS Forum

Present php in CSS
Basic but . . .

 9:33 pm on Jan 31, 2007 (gmt 0)

Hi Guys

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 "&copy; Mysite ".$currentdate["year"];

The basic php contained in CSS:

<div id="copyright">
$currentdate = getdate(time());
echo "&copy; Mysite ".$currentdate["year"];

Or do I need to include a purpose built css.inc file within the php - doh!

Thanks. . . .



 11:10 pm on Jan 31, 2007 (gmt 0)

You may handle it as your example is set
or keep your PHP file in an includes dir
and do an

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 :)


 11:19 pm on Jan 31, 2007 (gmt 0)

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"> &copy; 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.


 5:37 am on Feb 1, 2007 (gmt 0)

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.


 7:26 pm on Feb 1, 2007 (gmt 0)

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.


Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / CSS
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved