PEAR logo

HTML_CSS : The Definitive Guide

To File

HTML_CSS::toFile() is probably the most interresting solution. You can create a pure CSS file on the fly.

[Warning] Warning
If file already exists, it will be replace without warning !

This script will load an existing style sheet and replace the body definition :

      
<?php
require_once 'HTML/CSS.php';

$css = new HTML_CSS();

$css->parseFile('example.css');

$css->setStyle('body', 'background-color', '#0c0c0c');
$css->setStyle('body', 'color', '#ffffff');

$css->toFile('example.css');
?>
      
     

HTML_CSS : The Definitive Guide v 1.0.0 : June 24, 2006