What are some good PHP performance tips?

前端 未结 13 1717
挽巷
挽巷 2020-12-24 07:55

I\'ve heard of some performance tips for PHP such as using strtr() over str_replace() over preg_replace() depending on the situation.

13条回答
  •  醉梦人生
    2020-12-24 08:11

    This question (and the answers) are rather dated however it came up high in the listings when I googled for 'PHP performance'.

    While jgmjgm makes some good points, the execution time of PHP is typically a tiny proportion of the time a user spends waiting for a page to appear, but explaining why, let alone detailing the remedies would take far too long here.

    The first step is to identify the things which are taking the most time - and for a web based application you should start at the browser. Google Chrome has a good profiler and for Firefox, there is the Firebug extension. If the slow bit is PHP then dig further with a profiler such as xdebug, but remember that this will encompass any database and file IO.

提交回复
热议问题