raj
raj

Reputation: 31

CSS with a PHP extension?

I would like to name my css file mystyles.php. All content within will still be css. I'd like to then include this into my index.php page without using the standard HTML <link> tag. Any direction would be appreciated very much.

Upvotes: 2

Views: 307

Answers (2)

Jesse Dorsey
Jesse Dorsey

Reputation: 540

Start your mystyle.php file with.

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

Then echo out the elements.

Upvotes: 5

Sarfraz
Sarfraz

Reputation: 382656

Include styles in your mystyle.php file that should look like this:

<?php

<style type="text/css">
  /* your styles here.......... */
</style>

?>

Now you can include that file using include:

include `mystyle.php`

In the end i wonder why don't you use the stylesheet link instead.

Upvotes: 4

Related Questions