Jump to content

Dynamic css (Server Side)


FrostbiteXIII

Recommended Posts

It's not exactly a good practice, but yes... it's possible.PHP's output can be anything you want, so it doesn't really matter what it looks in the end.Let's say that with a PHP file, you create the CSS file "style.php". When displayed in a browser, it's plain text. Even though this file has a PHP extension, all the browser really cares for is the MIME type, specified in (X)HTML:<link rel="stylesheet" type="text/css" href="style.php" />and/or in the PHP file itself, sent with the header() function:

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

Link to comment
Share on other sites

It's not exactly a good practice, but yes... it's possible.PHP's output can be anything you want, so it doesn't really matter what it looks in the end.Let's say that with a PHP file, you create the CSS file "style.php". When displayed in a browser, it's plain text. Even though this file has a PHP extension, all the browser really cares for is the MIME type, specified in (X)HTML:<link rel="stylesheet" type="text/css" href="style.php" />and/or in the PHP file itself, sent with the header() function:
header("Content-type: text/css")

Thanks Boen Robot! :)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...