6

How would I go about using PHP as a CSS file. I have just included it as a normal css file, but it fails to work in Google Chrome.

4
  • please post the source of that php file Commented Feb 20, 2012 at 13:12
  • 6
    Do you set the content type header in the PHP file? Commented Feb 20, 2012 at 13:13
  • Do you want do use a css content saved as php file ? Is that what I undestood? Why such a thing? Commented Feb 20, 2012 at 13:14
  • 2
    @B4NZ41 sometimes people want dynamic CSS files. Commented Feb 20, 2012 at 13:24

2 Answers 2

10

You have to tell the browser that it is a CSS-file and not a HTML-file, write the following before any output:

<?php header("Content-type: text/css"); ?>

See: http://www.barelyfitz.com/projects/csscolor/

Sign up to request clarification or add additional context in comments.

Comments

8

Try adding

<?php header("Content-type: text/css"); ?>

in first line of your stylesheet.php

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.