DEV Community

Tips for optimizing PHP code for better performance

Theophilus Kolawole on January 06, 2023

PHP is a popular programming language that is widely used to build dynamic and interactive web applications. However, as the complexity and scale ...
Collapse
 
suckup_de profile image
Lars Moelleken
  1. APC, XCache, and eAccelerator are deprecated, you can still use e.g. APCu or Redis or Memcache for caching,... APCu could share memory between php-fpm processes

  2. Quotes are not relevant for the performance... the only way to speed things up, are profiling

  3. Global variables has nothing to do with performance but you are right, avoiding them is a good practice

  4. Yes, using newer versions of php are mostly faster

  5. Non prepare statements are faster if you do the query only once, if you do many similar queries then the extra prepare connection can be worth it.

Collapse
 
icolomina profile image
Nacho Colomina Torregrosa • Edited

4.- The last php8 version comes with JIT compiler which opens new chances for php as a language beyond web applications