i want to include my css/stylesheet via php so that...
<link rel="stylesheet" href="http://www.mydomain.com/css/style.php">
so that i can than dynamicly change different stylesheets.... how can i do that
As long as you set your MIME type in style.php
to CSS, you should be in business. Add this to the very top:
<?php Header ("Content-type: text/css; charset=utf-8");?>
Another option if you're running on an Apache server is to tell it to check .css files for PHP. Add this to your .htaccess
file to do this:
AddType application/x-httpd-php .css
Then you could simply include a regular .css file:
<link rel="stylesheet" href="http://www.mydomain.com/css/style.css">
You can add this php code in your html head section but file should be .php.
For example: index.php
<html>
<head>
<?php
$cssFile = "style.css";
echo "<link rel='stylesheet' href='" . $cssFile . "'>";
?>
</head>
<body>
...
...
</body>
</html>
You can store any css file path in $cssFile
variable using different conditions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With