Jump to content

Recommended Posts

My site runs quite slowly compared to others and im wondering if its the use of preg_replace in my template class. For example in my html page i would have [$root] which would be replaced by the template class using preg replace to the document root. This is just an example, i have loads more rules which replace stuff like that. So is preg_replace slow or are there other reasons why my site is slow?

Link to comment
https://forums.phpfreaks.com/topic/240509-preg_replace/
Share on other sites

There is some comparison for possible choices: http://www.php-scripts.com/php_diary/011303.php3 . Also if you dont have zillion of replaces I think its something else that is slowing down your site. Maybe you have some loops which makes some useless replaces many times or something like that?

Link to comment
https://forums.phpfreaks.com/topic/240509-preg_replace/#findComment-1235335
Share on other sites

So is preg_replace slow or are there other reasons why my site is slow?

 

The function may be "slow" depending on the regular expression and replacements being made, though in most normal cases it is not "slow" at all.  Have a look at profiling your script (search "xhprof", "xdebug") to find out really where the slow parts of the script lie, rather than guessing.

Link to comment
https://forums.phpfreaks.com/topic/240509-preg_replace/#findComment-1235341
Share on other sites

could it be then the inclusion of html files? for example, to return a list of the forums i run code which returns one html file and loop it for however many forums there is.

 

example of the included file:

 

{FORUM_NAME}

 

then i loop to render the forum name of each forum.

 

Could this be it since some of the html files which are looped consist of around 200 lines of html.

 

Link to comment
https://forums.phpfreaks.com/topic/240509-preg_replace/#findComment-1235519
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.