Welcome to WebmasterWorld Guest from 54.144.126.195

Forum Moderators: not2easy

Message Too Old, No Replies

Present php in CSS

Basic but . . .

     

Wonderstuff

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

10+ Year Member



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"];
?>
</div>

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

Thanks. . . .

henry0

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

WebmasterWorld Senior Member henry0 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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

topr8

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

WebmasterWorld Senior Member topr8 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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.

mep00

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

10+ Year Member



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

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

10+ Year Member



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.

W.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month