Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Senior Coder
    Join Date
    Apr 2003
    Location
    San Francisco, CA
    Posts
    2,469
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Can you use PHP in an external CSS?

    I've been using some random coding on an html document -- and to make it standard, I've been having it to randomize the colors of backgrounds and background images -- but I wasn't sure if I can put php in an external css document, so I've been placing it in the style="" section of the tag, and randomizing that.

    Can it parse in an External CSS document if I just add the file extension .php instead of .css -- are there any problems with this?
    // Art is what you can get away with. <-- Andy Warhol
    ...:.:::: bradyjfrey.com : htmldog : ::::.:...

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    As long as it has a .php extension the PHP engine will parse it, however I am not sure if the browser will parse the contents of it as an external style sheet without the .css extension.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #3
    Regular Coder
    Join Date
    Mar 2004
    Posts
    115
    Thanks
    0
    Thanked 0 Times in 0 Posts
    you could set the server up to parse .css

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Nah I do this all the time - all you have to do is send the right content-type header:
    Code:
    header("Content-Type: text/css");
    To save confusion, I'd give it a separate file extension like ".pcss" so you know what it is.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #5
    Senior Coder
    Join Date
    Apr 2003
    Location
    San Francisco, CA
    Posts
    2,469
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by brothercake
    Nah I do this all the time - all you have to do is send the right content-type header:
    Code:
    header("Content-Type: text/css");
    To save confusion, I'd give it a separate file extension like ".pcss" so you know what it is.
    Where do I adjust this at ?
    // Art is what you can get away with. <-- Andy Warhol
    ...:.:::: bradyjfrey.com : htmldog : ::::.:...

  • #6
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    within the php script you are wanting to use as CSS.

  • #7
    Senior Coder
    Join Date
    Apr 2003
    Location
    San Francisco, CA
    Posts
    2,469
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by missing-score
    within the php script you are wanting to use as CSS.
    Ah, I see it's time for a nap -- sorry about that, I should have known. Thanks for helping me out with this guys
    // Art is what you can get away with. <-- Andy Warhol
    ...:.:::: bradyjfrey.com : htmldog : ::::.:...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •