Jump to content


PHP + Dreamweaver Style Sheets

  • Please log in to reply
No replies to this topic

#1 phreakbear

  • Members
  • Pip
  • Newbie
  • 2 posts

Posted 19 January 2004 - 03:59 PM

I'm very new to PHP but am addicted. So far, I've just made a few simply PHP includes and echo statements.

But I was intrigued when I learned you can also learn PHP with style sheets. However, the online information I've discovered has been quite conflicting and confusing.

So I have two basic questions:

1. What's the point of using PHP with style sheets? Someone told me it's pointless, because style sheets are flexible enough, and they're even more powerful when combined with PHP includes.

But others claim that you can do some wonderful things if you stick PHP code directly into a style sheet. Is that true?

2. How do you get started?

My understanding is that there are two strategies for converting a style sheet into a PHP style sheet. Both begin with inserting the following code at the top of your style sheet:

header("Content-Type: text/css");

One method then requires you to change the style sheet's .css extension to .php. The other method requires you to insert the following code into a .htaccess file:

<Files ~ "\.css$">
ForceType application/x-httpd-php

The second method is the most confusing for me, because I haven't played with .htaccess files yet. I found one in my C:/xampp/webdav/ folder, but it sounds like I need to have one directly in my website, so I created a new file with Notepad, pasted the above code in and saved it right next to my home page.

I'm not yet certain if either method works, because I don't yet know what sort of PHP functions I can use on a style sheet to test it. However, I do have two problems.

When I change the style sheet's extension to .php, I lose the color coding that Dreamweaver inserts on my style sheet - except for the PHP code at the top of the page.

The other method kills the styles for about three elements on my page; specifically, it appears to remove my font-family settings. Of course, I'm not certain if I've actually implemented the other method, because I don't know what I'm doing. It's possible that the PHP code I inserted at the top of the page killed the styles. But it's the same code I inserted in the page with the .php extension.

Is there a way I can make this work without sacrificing the color coding in my style sheet?

* * * * * * * * * *

Those are my main questions at this point, but here are some other questions I'm pondering:

What are some of the really cool things I can do with PHP in a style sheet?

What does the code below mean? Can you include another page (with a .inc extension???) in a style sheet?

header("Content-Type: text/css");

Can you suggest a really simple PHP code I can use to see if my set up is working?

I ran across this code, but I don't yet have a clue what to do with it.

body {
background-color: #<?=$col[1]?>;
color: #<?=$col[1]?>;

<? if(something) { ?>
p {
font-size: 110%;
<? } ?>

/*etc etc*/


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users