I am not sure what I would call 100 million "several iterations." It seems you have accumulated about half a second of the difference, divide it by 100 million, and you will get a colossal difference of 5 nanoseconds per iteration if my math is correct. The difference is so small that it can simply lead to the fact that isset has only one operand in this context, and === - two.
It is impossible to even discuss the implementation details of the Zend mechanism of the two examples without specifying a specific version of PHP; source code is a moving target. Even minute changes in implementations will affect the results for many omissions. I would not be surprised if you find that the opposite occurs in some versions of PHP and / or in another context.
isset itself is covered by three different op codes in the virtual machine, depending on the context:
Simple compiled variables like your example: ZEND_ISSET_ISEMPTY_VAR
Arrays: ZEND_ISSET_ISEMPTY_DIM_OBJ (requires 2 operands, var and index)
Object properties: ZEND_ISSET_ISEMPTY_PROP_OBJ (also 2 operands, profile name and name)
This is an interesting question for the sake of curiosity, but we are in the field of hair splitting, and this is probably not a real optimization strategy.
Phil lewis
source share