PHP is a very fast programming language, but it is still worth optimizing PHP itself rather than just optimizing the code.
In this article, we will explain based on some practical results why optimizing PHP itself is more appropriate than optimizing the code, and why it is necessary to understand the performance of PHP in other related subsystems on your server to find bottlenecks and fix them. At the same time, we also mentioned how to optimize your PHP codes to make them execute faster.
Get high performance
When we talk about good performance, it often means more than just how fast your PHP code executes. Performance is a set of tradeoffs between quantifiable measurements and speed. Code that simply relies on using fewer resources may execute more slowly than code that runs in the cache, and the same set of code (that executes in the cache) can be executed concurrently on a Web server at the same time.
In the example below, A.php counts as a runner running as fast as possible, while B.php is a marathon runner who can run almost forever at the same slow speed. Under light load, A.php can be sufficiently fast, but when traffic increases, B.php's performance will only drop a little and A.php will collapse.