Reply
How do you use css with php?
Old 06-02-2008, 10:18 PM How do you use css with php?
scutari's Avatar
Skilled Talker

Posts: 95
Name: Indrit
Well this is important, I just can combine html and css perfectly. Php is kinda difficult to adapt with css.
What do you do?
__________________
Publishers
scutari is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 06-02-2008, 10:24 PM Re: How do you use css with php?
joder's Avatar
Flipotron

Posts: 6,443
Name: James
Location: In the ocean.
I have never had any problem. HTML and CSS embed well in PHP. Can you be more specific?
joder is offline
Reply With Quote
View Public Profile
 
Old 06-02-2008, 10:32 PM Re: How do you use css with php?
scutari's Avatar
Skilled Talker

Posts: 95
Name: Indrit
I mean if you use divs or how do you embed css with echo command?
__________________
Publishers
scutari is offline
Reply With Quote
View Public Profile
 
Old 06-02-2008, 10:44 PM Re: How do you use css with php?
joder's Avatar
Flipotron

Posts: 6,443
Name: James
Location: In the ocean.
The parts of a page you use html just use html and only use php for the parts that contain php - putting the <?php ?> tags around them.

To use HTML or CSS in PHP sections you echo it and the HTML looks almost exactly like in HTML pages. The difference is double quotes have to be escaped with a backslash (\).

http://www.tizag.com/phpT/echo.php
joder is offline
Reply With Quote
View Public Profile
 
Old 06-02-2008, 10:46 PM Re: How do you use css with php?
Capt Quirk's Avatar
Extreme Talker

Posts: 202
Location: Flordidian
I'm playing with this now. I created all the divs, and lined them up with css. Then I create the content of the div as the php. Probably not the preferred method, but it works. Once the php is brought in, it will follow the css that is attached to the page. I think..hehehe.
__________________
http://GuitarGarage.tv , up and limping along.
Capt Quirk is offline
Reply With Quote
View Public Profile
 
Old 06-02-2008, 11:59 PM Re: How do you use css with php?
Arenlor's Avatar
Ultra Talker

Posts: 463
Name: Jerod Lycett
Location: /home/arenlor
PHP is PHP Hypertext Preprocessor. Your PHP code is processed on your server and served to the client as HTML only. They never will nor can see your code. You use HTML/CSS in exactly the same way as usual, you just do something else before the HTML is sent and then processed by the agent. I'd suggest just using external stylesheets though, it's easiest.
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Old 06-03-2008, 02:13 PM Re: How do you use css with php?
Average Talker

Posts: 26
Name: Andy
You should be applying style markuping in a separate CSS file, rather than inline with <div style="ladeda"> as you seem to be suggesting.

That said, there is no reason for anything not to work with PHP - just make sure you are properly escaping your ' and "s with a \.
Pash is offline
Reply With Quote
View Public Profile
 
Old 06-03-2008, 05:19 PM Re: How do you use css with php?
wayfarer07's Avatar
$frontend->developer

Posts: 1,382
Name: Abel Mohler
Location: Asheville, North Carolina USA
In order to parse a .php file as CSS, you simply put this line at the top of the page:
PHP Code:
<?php header("Content-type: text/css"); ?>
Now you can link to link to the .php file as if it was a CSS file, and insert dynamic content into it. Not sure if this is what you're looking for, but it may come in handy.
__________________
<!--if a signature drops in the forest, and no one is there to see it, does it make a link?-->
wayfarer07 is online now
Reply With Quote
View Public Profile
 
Old 06-04-2008, 01:37 AM Re: How do you use css with php?
Arenlor's Avatar
Ultra Talker

Posts: 463
Name: Jerod Lycett
Location: /home/arenlor
Quote:
Originally Posted by Pash View Post
You should be applying style markuping in a separate CSS file, rather than inline with <div style="ladeda"> as you seem to be suggesting.

That said, there is no reason for anything not to work with PHP - just make sure you are properly escaping your ' and "s with a \.
Not should but can. If you know anything about CSS you will know that there are very good reasons for inline CSS. It's very specific, which means it'll override pretty much anything else (though I think !important may be able to override it). An internal stylesheet (contained in the header) is the next level up, while external stylesheets, which are meant to be shared between several pages, and therefore shouldn't be used if only one page is using it, rather use internal, are on the lowest end. So say you have in an external stylesheet body{background:#000000;}, which is used on pages A, B, and C. Pages A and B though both have internal stylesheets which have body {background:#FFFFFF;} and page A has style="background:#A0A0A0;" on its body tag. Page A would have the gray background (#A0A0A0), page B would have white (#FFFFFF) and page C would have black (#000000). PHP works with all three methods just like any HTML does.
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Reply     « Reply to How do you use css with php?
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Webmaster Resources Marketplace:
Software Development Company | Webhosting.UK.com | Text Link Brokers 


   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.15863 seconds with 12 queries