TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 05-26-2010, 09:11 PM   #1 (permalink)
The Wanderer
 
Join Date: Jan 2010
Posts: 10
Thanks: 4
Monferno is on a distinguished road
Arrow 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(); 
Monferno is offline  
Reply With Quote
Old 05-26-2010, 10:24 PM   #2 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

I could see that being useful if implemented in a framework - I'd like to see it perform some simple optimizations that most people don't like to do themselves (for some reason) such as looking for rules like border-radius and automatically generating -moz, -khtml and -webkit versions. Shortening color values from #ffffff to #fff or #cc0000 to #c00 would be cool, same with box model settings, margin: 15px 10px 10px 10px to margin: 15px 10px 10px and so on and so forth.
delayedinsanity is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't get PHP 5. to work? Newbie windows PHP guy DotNetTim Absolute Beginners 11 02-01-2013 11:02 AM
10 PHP Myths Dispelled Wildhoney General 9 06-15-2009 06:55 AM
PHP Compressor Kalle Script Giveaway 8 05-28-2008 12:14 AM
what are all the subjects in php? sarmenhb General 7 01-21-2008 05:41 PM


All times are GMT. The time now is 06:37 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design