Use php variables in multiple css files -


i know can ask php file act css one, did. problem how use variables in css-php files ? css.php file global variables loaded before others in html list, doesn't seem includes it.

my html :

<link rel="stylesheet" type="text/css" href="assets/css/variables.css.php"> <link rel="stylesheet" type="text/css" href="assets/css/main.css.php"> 

my variables.css.php file :

 <?php    header("content-type: text/css");    $color = "#004d7f";  ?> 

my main.css.php file :

<?php header("content-type: text/css");  ?> body {     background: <?=$color;?>; } 

but doesn't work, doesn't recognize variable $color. tried add @ main.css.php :

require("/assets/css/variables.css.php"); 

but threw error. know answer ? how access php variables in php file acting css ?

thank in advance !

-- carlos

what web server sees not browser sees. specifically, while path file http://domain/assets/css/variables.css.php, on server side need reflect location actual code. leading forward slash, server looking file starting root of filesystem.

remove leading slash

that may enough make work if relative path correct

if doesn't help,

remove parts of path until works

if both files sitting in /var/www/html/assets/css/, doing require("variables.css.php") enough.


additionally, there's no need include variables.css.php inside webpage. php populate values automatically inside main.css.php.


Comments

Popular posts from this blog

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -

javascript - Using jquery append to add option values into a select element not working -

javascript - Restarting Supervisor and effect on FlaskSocketIO -