Login   Register  
PHP Classes
elePHPant
Icontem

File: test.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Michael Ettl  >  parseCSS  >  test.php  >  Download  
File: test.php
Role: Example script
Content type: text/plain
Description: Example of parsing/generating css
Class: parseCSS
Class for parsing CSS Stylesheets
Author: By
Last change:
Date: 11 years ago
Size: 1,179 bytes
 

Contents

Class file image Download
<?php
include_once("parseCSS.inc");
$oCSS=new CSS();
?>
<html>
</html>

<h3>Parse CSS from File</h3>

<?php

$oCSS
->parseFile("style.css");

foreach(
$oCSS->css as $key0 => $value0) {
    echo 
"</ul>$key0<ul>\n";
    foreach(
$oCSS->css[$key0] as $key1 => $value1) {
        echo 
"\t<li>$key1:$value1\n";
    }
}
?>
</ul><hr>
<h3>Tell me what property has body->font-size<br>
<?=$oCSS->css["body"]["font-size"]?></h3>

<h3>Parse CSS from String</h3>

<hr>

<?php
$string
="body {
    font-family: Arial;
    font-size: 10pt;
    font-style: normal;
}

body.top {
    font-family: Arial;
    font-size: 10pt;
    text-decoration: none;
    }"
;
    
$oCSS->parse($string);
foreach(
$oCSS->css as $key0 => $value0) {
    echo 
"</ul>$key0<ul>\n";
    foreach(
$oCSS->css[$key0] as $key1 => $value1) {
        echo 
"\t<li>$key1:$value1\n";
    }
}
?>
</ul><hr>
<h3>Generate CSS</h3>
<?php

    $oCSS
->css["body"]["background-image"]="url(background2.gif)";
    
$oCSS->css["body"]["font-family"]="Times New Roman";
    echo 
"<PRE>".$oCSS->buildcss()."</PRE>";

?>
<hr>
<h3>What Tags are in array</h3>
<ul>
<?php
foreach($oCSS->csstags as $value0) {
    echo 
"<li>$value0</li>\n";
}
?>
</ul>