Scaling Impacts of Objects and Their Methods

As languages change from being procedural to object-oriented, the required number of CPU cycles increases. It is often said that method calls that are twice as slow as identical function calls are an acceptable cost for the use of objects in any language. This time multiplier of two is not a reduction of the speed of the code within a method. It is the amount of time required to begin executing the code within the method. It is true that in PHP, methods are slower than functions. It is also true that in PHP, calling code within a function takes more time than executing the same code outside of any function.

For PHP, the cost of moving from functions to methods is not a factor of two. It is generally ...

Get Oracle Database Ajax & PHP Web Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.