Chapter 14. Performance Tuning
Dynamically interpreted languages, such as PHP, are known for their flexibility and ease of use but not necessarily for their speed. This is partly because of the way their type systems work. When types are inferred at runtime, it’s impossible for the parser to know exactly how to perform a certain operation until it’s provided with data.
Consider the following, loosely typed PHP function to add two items together:
function
add
(
$a
,
$b
)
{
return
$a
+
$b
;
}
Since this function does not declare the types for the variables passed in or the return type, it can exhibit multiple signatures. All of the method signatures in Example 14-1 are equally valid ways to call the preceding function.
Get PHP Cookbook 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.