PHP array, is it a performance killer?

We have seen in this chapter how each element in a PHP array has a very big overhead of memory. Since it is done by the language itself, there is very little we can do over here, except that we use SplFixedArray instead of a regular array where it is applicable. But if we move from our PHP 5.x version to the new PHP 7, then we can have a huge improvement in our application, whether we use regular PHP array or SplFixedArray.

In PHP 7, the internal implementation of a hash table has been changed drastically and it is not built for efficiency. As a result, the overhead memory consumption for each element has gone down significantly. Though we can argue that less memory consumption does not make a code speedy, we can have a counter argument that if we have less memory to manage, we can focus more on execution rather than memory management. As a result, we have some impact on the performance.

So far from the discussion, we can easily say the newly improved array in PHP 7 is definitely a recommended choice for developers to solve complex and memory efficient applications.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset