I got a PHP named data.php
and it looks like this:
<?php
$my_color = 'red';
?>
And I wanna use its value for a CSS property. The main PHP named style.php
looks like this:
<?php
header("Content-type: text/css; charset: UTF-8");
include 'data.php';
?>
.test {
background-color: <?php echo $my_color; ?>;
}
But this is not working because if I inspect it in the network of the developer tool, the value is actually blank and looks like this: background-color: ;
. Anything I do it wrongly?
Edited: After looking at the error log, it shows: Undefined variable: my_color
. But the file data.php
and style.php
are in the same folder. For example, the folder name is called plugin
, and both files are in this folder, no other folder and file there.