View Full Version : Something I've never understood ....

07-10-2009, 03:00 PM
Is why you can't, for example, use some pass-by-value functions inside each other.

For example, you can't have:

empty(array_diff($ar1, $ar2));

without getting a write-context error.

Instead you must use:

$diff = array_diff($ar1, $ar2);

Why?? None of the arguments to empty are references so I don't see what the Zend engine has to complain about!

It's just something that has bugged me ever since I first came across it ...

I notice this happens in a number of other cases when the argument that is being complained about is not being passed by reference.

07-10-2009, 06:50 PM
I think it's because empty() is a language construct, not a function. I don't really know why that limits it though...