PEAR logo

HTML_CSS : The Definitive Guide

Parse a file contents

Another quick way to create multiple selector definitions in one step is to use the HTML_CSS::parseFile() function. CSS file to load is supposed to be W3C/CSS compliant.

If previous selector definitions was into a file named 'styles.css', then to parse and load contents will be done with such script :

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

$css = new HTML_CSS();
$css->parseFile('styles.css');
$css->display();
?>
      
     

[Tip] Tip
If there are duplicate definitions into file contents, you should parse file with call :

$css->parseFile('styles.css', true);

We will see next why we may find such duplicate definitions.

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