Jump to content

CSS into php code


phppaper

Recommended Posts

Sometimes there are reasons for having CSS in a php file, like the CSS is stored in a database table.

 

What you want to do is put a header() call at the top:

 

<?php
header('Content-type: text/css;');
echo 'h2 {color: #FF0000;}';
?>
/* Here is more static stuff */
h3 {font-size: 10pt;}

 

Then reference it from an HTML page just like a normal CSS file (but the URL will be to styles.php instead)

Link to comment
https://forums.phpfreaks.com/topic/97721-css-into-php-code/#findComment-500081
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.