Search code examples
phpoutput-buffering

If I use buffering will that have significant effect on performance?


I have a client who wants his script to be tweaked for some modifications. Unfortunately, most of the code is 'ionCubed'. Now I thought I can use ob_start($callback) to buffer the output and change it by using RegExes. My question is will that have significant effect on loading of the script? or are their any better alternatives to do it?


Solution

  • The output buffering should not have much influence in terms of speed but will of course use as much memory as the output's size is. The RegEx might however be a performance impact depending on the type of replacements your are doing. use str_replace where possible.

    At the end it is always going to be some sort of trade-off. You should implement a basic example of what you want to do in the end and compare performance with the unmodified version. You could also try disassembling the encoded script and change it directly, although that could be quite challenging depending on what kind of replacements you want to do.

    Also keep in mind that it is usually much simpler to do one str_replace to get your custom CSS in there if you want to do optical changes.