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
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 08-26-2009, 09:48 PM   #1 (permalink)
The Contributor
 
hello-world's Avatar
 
Join Date: Feb 2009
Posts: 73
Thanks: 30
hello-world is on a distinguished road
Default Template How ? ?

After a long period of time I understand how to separate php from html.The book php in Action has lots of details about.
But now there is one problem that it is slower than I thought.
Here I have include this file.Can you please tell me why is that so ?

PHP Code:
Class Template {
    public 
$data;
    public 
$file;
    
    public function 
__construct($file,$var,$value){
         
$this->file file_get_contents($file);
         
$this->data[$var] = $value;
         
    }
    
    public function 
set(){
        
//Search for any thing side {} and Save the result in matches(array)
        
preg_match_all("/{.*?}/",$this->file,$matches);
        
        
//loop through the result of matches
        
foreach($matches as $skey => $value){
            
//loop through data
            
foreach($this->data as $val ){
            
            if(
in_array($val,$value)){
                
                foreach(
$this->data as $myKey =>$valo)
                
                
$string =str_replace($val,$myKey,$this->file);
                
                 eval(
"?>".$string);
                
                } else {
                    echo 
"not found";
                    echo eval(
"?>".$this->file);
                    
                     break; 
                }
            }
        }
    }
    
    public function 
parser(){
        
ob_start();
        
$this->set();
        
$string ob_get_contents();
        
ob_get_clean();
        return  
$string;
    }

hello-world is offline  
Reply With Quote
 



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
Template Phraser Scottymeuk Advanced PHP Programming 7 01-08-2009 09:07 PM
Template Class Issues WinSrev Advanced PHP Programming 20 11-04-2008 05:05 PM
Pure PHP template class. abiko Advanced PHP Programming 1 04-02-2008 05:45 PM
Template / Theme Parsing and Management TerrorRonin Advanced PHP Programming 6 03-18-2008 07:47 PM
Different style template system? Nor General 2 01-15-2008 01:10 PM


All times are GMT. The time now is 02:54 PM.

 
     

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