home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / function.eval.php < prev    next >
Encoding:
PHP Script  |  2004-03-24  |  925 b   |  49 lines

  1. <?php
  2. /**
  3.  * Smarty plugin
  4.  * @package Smarty
  5.  * @subpackage plugins
  6.  */
  7.  
  8.  
  9. /**
  10.  * Smarty {eval} function plugin
  11.  *
  12.  * Type:     function<br>
  13.  * Name:     eval<br>
  14.  * Purpose:  evaluate a template variable as a template<br>
  15.  * @link http://smarty.php.net/manual/en/language.function.eval.php {eval}
  16.  *       (Smarty online manual)
  17.  * @param array
  18.  * @param Smarty
  19.  */
  20. function smarty_function_eval($params, &$this)
  21. {
  22.     extract($params);
  23.  
  24.     if (!isset($var)) {
  25.         $this->trigger_error("eval: missing 'var' parameter");
  26.         return;
  27.     }
  28.     if($var == '') {
  29.         return;
  30.     }
  31.  
  32.     $this->_compile_template("evaluated template", $var, $source);
  33.     
  34.     ob_start();
  35.     eval('?>' . $source);
  36.     $contents = ob_get_contents();
  37.     ob_end_clean();
  38.  
  39.     if (!empty($assign)) {
  40.         $this->assign($assign, $contents);
  41.     } else {
  42.         return $contents;
  43.     }
  44. }
  45.  
  46. /* vim: set expandtab: */
  47.  
  48. ?>
  49.