Location: PHPKode > projects > PHP Object Oriented Framework > poof/Parser.class.php
<?php
/*
    This file is part of POOF.

    POOF is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
    
    POOF is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
    along with POOF; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

/**
* The template processor.
* @package poof
* @since Version 0.4
* @author Brian Takita <hide@address.com>
* @version 0.4
*/
class Parser {
    /**
    * @var    mixed A variable to put temporary data. This should not be used to store data.
    * @access private
    */
    var $_temp;
    
    /**
    * Parse valid PHP and return the result.
    * @return string The result of the parsed data.
    * @param  string &$string   The string to be parsed. This string should be valid PHP.
    * @param  array  $variables The variables parsed in $string.
    */
    function &parse(&$string, &$variables) {
        $this->_temp = &$string;
        
        extract(&$variables);

        ob_start();
            $this->_temp = " ?>" . $this->_temp . "<?php ";
            eval($this->_temp);
            $this->_temp = ob_get_contents();
        ob_end_clean();
        
       return $this->_temp;        
    }
}
?>
Return current item: PHP Object Oriented Framework