How to control CSS. PHP?


I am working on an application that creates a website template and there is an options page where the user will be able to change colors (via a colorpicker script) of the stylesheet. One option I found is to use PHP to control CSS variables (as described here). I was wondering if there are other options, possibly better options to do what I want to do.

Thanks for any ideas.

I have just changed one of my sites and started afresh with using a THEME.php file to save five colours then to import the colours into the stylesheet:

// Save THEME.php

  $colours = '"' .'#fff #900  #f90  #f60  #f30 rgb(255,240,140)' .'";' ;

  $data = "<?php "	.'$ccc=' .$colours;   // BEWARE - uses PHP so CANNOT ECHO
  $path = str_replace('ci_jokes\\\\','', FCPATH);
  $file_tmp = $path .'subs\\assets\\css\\__THEME__.php';

  $result = write_file($file_tmp, $data);

  // contents of __THEME__.php
  // <?php $ccc="#fff #900  #f90  #f60  #f30 rgb(255,250,220)"; 

// stylesheet.php

  # Excellent Responsive design tester with some good links to check out
  # Good colour picker
#echo THEME ;
if( file_exists('__THEME__.php') )
  require '__THEME__.php';
  if( isset($theme_unlink) && $theme_unlink )
    unlink( '__THEME__.php');
  $ccc = str_replace('  ',' ', $ccc);
  $ccc = explode(' ', $ccc);
  	'#fff', 		#  body colour
  	'#FF1493', 	#  Pink Deep
  	'#FF69B4',	#  Pink Hot
  	'#FFB6C1',	#  Pink XXX
  	'#FFB6C1',	# '#FFC0CB';
  $ccc[] = 'rgb(255,245,245)';	# Pink Light - PHP Functions NOT allowed in array()
  $bg=array(); foreach($ccc as $b) {$bg[]='background-color:' .$b;}

$bg=array(); foreach($ccc as $b) {$bg[]='background-color:' .$b;}
header("Content-type: text/css;charset:UTF-8");


body {background-color: <?=$ccc[0];?>; color: >?=$ccc[1]'?>}

.btn1 {background-color:<?=$ccc[1];?>; color:<?=$ccc[0];?>;border-color: <?=$ccc[1];?>}
.btn2 {background-color:<?=$ccc[2];?>; color:<?=$ccc[0];?>;border-color: <?=$ccc[2];?>}
.btn3 {background-color:<?=$ccc[3];?>; color:<?=$ccc[0];?>;border-color: <?=$ccc[3];?>}
.btn4 {background-color:<?=$ccc[4];?>; color:<?=$ccc[0];?>;border-color: <?=$ccc[2];?>}
.btn5 {background-color:<?=$ccc[5];?>; color:<?=$ccc[1];?>;border-color: <?=$ccc[1];?>}

// usage

<?php // $file_CSS = URL_ASSETS .'css/vo13-scrn-nor.css?ver=121023';?>
<?php    $file_CSS = URL_ASSETS .'css/vo13-scrn-nor.php?ver=121023';?>

<link media="screen,projection,tv" href="<?php echo $file_CSS;?>" type="text/css"  rel="stylesheet" />

My Problem which is still to be resolved:

How to read the genrated PHP file using PHP and to save it as a CSS file.

Currently I use FireFox:

  1. display the contents
  2. click on THEME.php file
  3. highlight and copy all contents into a keyboard buffer
  4. save the keyboard buffer to the style.css so that it can be validated using “