05-26-2010, 09:11 PM
|
#1 (permalink)
|
|
The Wanderer
Join Date: Jan 2010
Posts: 10
Thanks: 4
|
Css Php
THis PHP script allows you to style your web pages using PHP.
PHP Code:
class CPHP { var $style; function CPHP() { $this->style = array(); } public function addSelector($name, $attr) { $this->style[] = "$name/@/$attr"; } public function output() { print "<pre>"; print_r($this->style); print "</pre><style type='text/css'>"; foreach ($this->style as $s) { $style = explode('/@/', $s); print $style[0] . '{' . $style[1] . '}'; } print "</style>"; } } $cphp = new CPHP; $cphp ->addSelector('h1', 'color: red; font-family: Sans-Serif;'); $cphp ->addSelector('h2', 'color: orange'); $cphp ->addSelector('h3', 'color: blue'); $cphp ->addSelector('p', 'color: green'); $cphp ->addSelector('p', 'background-color: red'); $cphp ->addSelector('h1', 'background-color: orange'); $cphp ->addSelector('h2', 'background-color: blue'); $cphp ->addSelector('h3', 'background-color: green'); $cphp ->output();
|
|
|
|