Rahul's Work

add this class Template :

class Template {     const DIRECTORY = '';     protected $path;     protected $extendedTemplate = null;     protected $sections = array();     protected $currentSection = null;     public function extend( $name )     {         $this->extendedTemplate = new Template( "views/".$name );     }     public function begin( $sectionName )     {         ob_start(); // start output buffering         $this->currentSection = $sectionName;     }     public function end()     {         if ( !is_null( $this->extendedTemplate ) )         { // current one is a sub template             // read buffer contents and drop them             $this->sections[ $this->currentSection ] = ob_get_clean();         }         else         { // current one is a master template             if ( isset( $this->sections[ $this->currentSection ] ) )             {                 ob_end_clean(); // drop default content                 echo $this->sections[ $this->currentSection ];             }             else             {                 // output buffered data…

View original post 303 more words

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s