Use php varibals in css style sheets

0

I have the following code. The session variables are full but for some reason when I use it below the variable $colorNav considers it empty, someone can help me

PHP:     

$colorHeader = "'".$_SESSION['_colorHeader']."'";
$colorNav = "'".$_SESSION['_colorNav']."'";
$colorLetrasNavNopulsadas = "'".$_SESSION['_colorLetrasNavNopulsadas']."'";
$colorLetrasNavPulsadas = "'".$_SESSION['_colorLetrasNavPulsadas']."'";
$colorSubNav = "'".$_SESSION['_colorSubNav']."'";
$colorFooter = "'".$_SESSION['_colorFooter']."'";
$colorFooterLetras = "'".$_SESSION['_colorFooterLetras']."'";
$colorBuscadorLetras = "'".$_SESSION['_colorBuscadorLetras']."'";
$colorCajaBuscador = "'".$_SESSION['_colorCajaBuscador']."'";
$colorWeb = "'".$_SESSION['_colorWeb']."'";
$colorHipervinculos = "'".$_SESSION['_colorHipervinculos']."'";
$fondoLogo = "'".$_SESSION['_fondoLogo']."'";
$letrasLogo = "'".$_SESSION['_letrasLogo']."'";
$colorGestutelar = "'".$_SESSION['_colorGestutelar']."'";
$colorLetrasSubNavNoPulsadas = "'".$_SESSION['_colorLetrasSubNavNoPulsadas']."'";
$colorLetrasSubNavPulsadas = "'".$_SESSION['_colorLetrasSubNavPulsadas']."'";
$colorCuadroSubNavPulsadas = "'".$_SESSION['_colorCuadroSubNavPulsadas']."'";
?>

CSS:

*, html {
    margin: 0;
    padding: 0;
}
html, body {
   height:100%;
}
body {
    font-family: Geneva,Arial,Helvetica,sans-serif;
    background: none repeat-x scroll 0 170px <?=$colorNav?> ;
    color: #333333;
}
    
asked by Francisco Javier Moivas Rodrig 29.03.2017 в 23:44
source

1 answer

1

I do not think I'm taking the empty variable, but that CSS does not detect color values in single quotes.

background: red /* Funciona */
background: 'red' /* No Funciona */

The solution is to not add (remove) the single quotes at the beginning and end of your session variable

    
answered by 30.03.2017 в 00:05