I am trying to process some CSS using PHP. The CSS I want to process is page-specific and so I want to set a variable in my index.php
to only echo the CSS when the variable is set.
index.php
<?php
$name = 'index';
?>
<?php
include 'inc/header.php';
?>
header.php
<head>
<meta charset="utf-8">
<title></title>
<?php include 'import.php'; ?>
</head>
import.php
<link rel="stylesheet" href="css/styles.css.php" type="text/css" />
The header is properly set for this file. and the CSS is interpreted.
styles.css.php
.jumbotron {
background-image: url(../img/jumbotron.jpg);
<?php
if ($name === "index") {
echo("height: 50VH;"); /* Does not echo anything*/
}
var_dump($name); // Evaluates to NULL
?>
}
How can I make sure $name
is set to it's value, as set in index.php
?
EDIT: My final solution was to make an object from the stdClass
and add the variables I needed as attributes to the object. putting a GET request in the link to the CSS file which was the Base64 of the JSON string of the object.