Re: RE: Form.php - why returnStart ?

From: Date: Sat, 27 Jan 2001 12:34:53 +0000
Subject: Re: RE: Form.php - why returnStart ?
References: 1  Groups: php.pear 
Request: Send a blank email to php-pear+get-1201@lists.php.net to get a copy of this message
Bertrand Mansion wrote: > I was also wondering if there was a way to cache templates so that they > won't have to be opened from the disk every time a page is opened. This is a > topic I am completely ignorant of. As far as I noticed that won't help. Most webservers have already a filesystem cache. There're rare situations when you have to read the template from disk. In those cases it's still really fast to get say a 8 - 24 kb template file. Drive a test using a static variable to cache the template file I'm afraid you won't get a mentionable speed up. The disk access does not determine the speed of the template system. It's the function used to do the replacements. Try Smarty if you worry about speed, http://www.phpinsider.com/php/code/Smarty/. For me any template system using preg_replace() was always fast enough. preg_replace() can take arrays of patterns and replacements and by this save some function call over str_replace() and it uses an internal regcomp() cache (as ereg_*). On top of this the regexp compiler can generate code that searches faster than in linear time as str_replace() does. Depending on the test scenario preg_replace() is sometimes about 20-30% slower but str_replace() and sometimes even faster. Usually I suggest using str_replace() for simple templates and preg_replace() for template systems that handle "blocks". By the way, this is why I think one should be famillar with exactly two template systems of our choice - one line EasyTemplate (phpChat) and one like a modified QuickTemplate (stinky, slow ereg* replaced by preg*) or the classical PHPLib template (FastTemplate like API) or IT[X]. Ulf

« previous php.pear (#1201) next »