A Yes, because the interpreter must always create a copy of the array before passing it to the function.
B Yes, but only if the function modifies the contents of the array.
C Yes, but only if the array is large.
D Yes, because PHP must monitor the execution of the function to determine if changes are made to the array.
E No.
+ ExplanationThis question is a bit convoluted, so it’s easy to get lost in it. For starters, notice that it specifies two important assumptions: first, that you do not have any compelling reason for passing the array either way. If you needed a function to modify the array’s contents, you’d have no choice but to pass it by reference—but that’s not the case here. Second, the question
specifies that we’re passing the array to a read-only function; if this were not the case, Answer B would be true, since a change of the array would cause an actual copy of the array to be created. As a general rule, however, passing an array by reference to a function that does not modify its contents is actually slower than passing it by value, since PHP must create a set of structures that it uses to maintain the reference. Because PHP uses a lazy-copy mechanism (also called copy-on-write) that does not actually create a copy of a variable until it is modified, passing an array by value is a very fast and safe method of sharing an array with a function and, therefore answer E is correct.