Parse multiple
data sources at once
In this example, here are our goals :
- load CSS definitions from a simple PHP string
- load CSS definitions from multiple CSS files
Here is content of print.css
file :
-
*{
-
margin: 4px;
padding: 0px;
-
}
-
-
body{
-
font-family: Tahoma, Verdana,
Helvetica, Arial, sans-serif;
-
text-align:center;
-
background-color:#fff;
-
}
Here is content of default.css
file :
-
*{
-
margin: 0px;
padding: 0px;
-
}
-
-
body{
-
font-family: Lucida Grande, Tahoma,
Verdana, Arial, sans-serif;
-
text-align:center;
-
background-color:#fff;
-
}
Example 11.4. Multiple data sources parsing
-
<?php
-
require_once 'HTML/CSS.php';
-
-
$styles = array(
-
"body { font-size: 1em;
}",
-
"print.css",
-
"default.css"
-
);
-
-
$css = new
HTML_CSS();
-
$css->parseData($styles);
-
$css->display();
-
?>
And here are the result we should expected :
-
body {
-
font-size: 1em;
-
font-family: Lucida Grande,
Tahoma, Verdana, Arial, sans-serif;
-
text-align: center;
-
background-color: #fff;
-
}
-
-
* {
-
margin: 0px;
-
padding: 0px;
-
}