Can I include php in css stylesheet?

A

Anonymous

Guest
Hello.

I'm currently looking into the possibility of using css.
At present I've just using TopStyle's css software and got a new Style Sheet from template.

I'd just like to ask if I can include a php file, and if so how do I go about it please.
I've tried using include and the line [ ] and
iframe both in html but neither work.

I can't remember if I should use something else.

Thank You
Ian.
 
If your server is set up to parse css files then you can, otherwise you will need to do something like this:
Code:
<link rel='stylesheet' type='text/css' href='styleheet.php' />
An example could be
Code:
<?php
header("Content-type: text/css; charset: UTF-8"); # note this line is before the echo
$font-colour = #89a;
echo <<< css
html {
  font-size: 16px;
  color: $font-colour;
  margin: 0;
  padding: 0;
}
css;
The line that you are trying to insert is pointless, css is used for displaying html elements - nothing else - I would think that you need to do something else to achieve whatever it is you are trying to achieve.

HTML and CSS do not process as such, they are mostly static*. PHP will process on the server side and JavaScript will process on the client (browser) side.

* There are exceptions to this, but the processing that can be done is fairly limited / restricted and certainly not in the same way that you are looking at.
 
Hello Hyper,

Thank you for your reply.

Kind Regards
IChaps.
 
Hello Hyper,

What I've attempted to do is,

create a table with 1 row and 3 columns.
In:-
Column 1: include a menu created in php
Column 2: include another php file.
Column 3: include either a graphic or another php file.

I've attempted to create a 3 blocks side by side, but was unable to achieve this, that's why I started using css.

Thanks.
 
What I suggest is that you do a beginners tutorial in html and css before you carry on with php, there are fundamental differences between each of them and short answers to will not help you.
 
Hello Hyper. :)

Hope you are ok.
Just a short note to say I've achieved what I wanted to do.
It was a minor glitch in my css software setup, and I've also using iframe which I forgot about at the start.

Thank you for your replies and help.
Kind Regards
IChaps.
 
I'm not sure what you are asking:

Question:-Do you need to know php to learn css?
Answer:-No.

Question:- Do you need to know css to learn php?
Answer:- Strictly speaking no, in practice you do need to know css & html if you want to create web pages with php.
 
Back
Top