Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
02-02-2010, 05:02 AM #1
Will using a custom "template" (HTML Page) impact performance?
- By Performance, I mean speed + memory load.
- Template denotes some sort of file that is to be eval'd
... <body> <div id="content"> <h2 class="title">|title|</h2> <div class="post">|post|</div> </div> </body> ...
So my question is, will this method be have a large performance impact on a server vs a normal <?php echo $title; ?> or not? In what circumstances will this cause the server's performance to drop (i.e. will lots of visitors cause it to decrease or what?)
02-02-2010, 12:19 PM #2
- Join Date
- Dec 2009
- Thanked 58 Times in 58 Posts
It will have an impact, but nothing major unless you are running it on a crappy shared host with thousands of users accessing it
02-02-2010, 12:58 PM #3
- Join Date
- Mar 2006
- Thanked 37 Times in 37 Posts
By regular-expression-replacing you mean preg_replace() ? I would advise to replace with str_replace(). String functions are faster than regexp functions.
Of course the patterns to replace would need to be unique enough not to be met in the common page text by any chance (str_replace() will replace all strings it finds with the given replacement string).
Also you could submit arrays to str_replace() to replace many patterns with 1 function call.
Edit: Just in case: Also you said you would eval it to output a basic HTML page. I hope you would not use the function eval() ... There is no need for it - you could simply echo the resulting string after replacement. Also if eval() is used, it is necessary to be absolutely sure no one could attack the system by injecting some code. Normally I would use eval() only if I was sure it was absolutely safe and I was sure there was no way to avoid using this function.
Last edited by SKDevelopment; 02-02-2010 at 01:18 PM.