Código:
Y no entiendo desde: $this->mihtml = preg_replace('#\{([a-z0-9\-_]*?)\}#is', "' . $\\1 . '", $this->mihtml); que es donde pasa de ser {variable} a $variable<? class plantilla{ function plantilla($template_file){ $this->tpl_file = 'plantillas/' . $template_file . '.tpl'; } function asigna_variables($vars){ $this->vars= (empty($this->vars)) ? $vars : $this->vars . $vars; } function muestra(){ if (!($this->fd = @fopen($this->tpl_file, 'r'))) { sostenedor_error('error al abrir la plantilla ' . $this->tpl_file); } else{ $this->template_file = fread($this->fd, filesize($this->tpl_file)); fclose($this->fd); $this->mihtml = $this->template_file; $this->mihtml = str_replace ("'", "\'", $this->mihtml); $this->mihtml = preg_replace('#\{([a-z0-9\-_]*?)\}#is', "' . $\\1 . '", $this->mihtml); reset ($this->vars); while (list($key, $val) = each($this->vars)) { $$key = $val; } eval("\$this->mihtml = '$this->mihtml';"); reset ($this->vars); while (list($key, $val) = each($this->vars)) { unset($$key); } $this->mihtml=str_replace ("\'", "'", $this->mihtml); echo $this->mihtml; } } } ?>
Tambien si me podeis explicar la funcionalidad de la doble $, me acuerdo de haberlo usado pero no de para que servia.
En link de la pagina del codigo: http://www.cristalab.com/tutoriales/creacion-y-uso-de-plantillas-o-templates-en-php-c132l/
Gracias!