Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS with a PHP extension?

Tags:

html

css

php

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.

like image 330
raj Avatar asked Jul 14 '26 20:07

raj


2 Answers

Start your mystyle.php file with.

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

Then echo out the elements.

like image 76
Jesse Dorsey Avatar answered Jul 16 '26 11:07

Jesse Dorsey


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.

like image 42
Sarfraz Avatar answered Jul 16 '26 13:07

Sarfraz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!