When using an external stylesheet, is it possible to use a PHP object within CSS - without creating another object?
I have found workarounds with internal and inline CSS (e.g. How to include PHP code in CSS?) Below is some minimal code to show the problem and the workarounds I have found thus far.
in MyClass.php:
class MyClass{
public $color = "blue";
}
in PHP/HTML file:
<?php
include_once('MyClass.php');
$myClass = new MyClass();
?>
... (in head - internal CSS workaround):
<style type="text/css">
h1{color: <?php echo $myClass->color;?>;}
</style>
... (in head - external CSS workaround):
<link rel="stylesheet" href="external.css") />
... (in body):
<h1> 1. Internal </h1>
<h2 style="color:<?php echo $myClass->color;?>"> 2. Inline </h2>
<h3> 3. External </h3>
In external.css [here is the "problem" - I need to create a new object]:
<?php
header('Content-type: text/css');
include('myClass.php');
$myClass = new MyClass(); //<--ANOTHER OBJECT
?>
h3 {
color: <?=$myClass->color?>;
}
.cssfiles through PHP?