All pastes #253584 Raw Edit

Untitled

public text v1 · immutable
#253584 ·published 2006-11-20 22:15 UTC
rendered paste body
    <?php
    class parseTemplateFile {
        var $output;

        function parseTemplateFile($templateFile){
                   $this->output=file_get_contents($templateFile);
        }

        function assign($key, $val)
                {
    global $ar1, $tempVARS;

    $ar1 = array("$key" => "$val");

    $tempVARS = array_merge($ar1, $tempVARS);

                }
        function parseTemplate($tempVARS=array()){

                   foreach($tempVARS as $tag=>$data){

$data=$this->output=str_replace('{$'.$tag.'}',$data,$this->output);

                   }

        }
        function display(){

$this->output=preg_replace('/{\$(.+)}/','', $this->output);
              return $this->output;
             unset($this->output);
        }
    }


    ?>