I'm having a class that implements the ArrayAccess
interface. I noticed that I can use empty
function on the offset values with no errors:
$class = new MyArrayClass();
if(!empty($class["offset"]))
...
else
die("Empty!!!");
However calling even the offsetGet
interface method will not work:
if(!empty($class->offsetGet("offset")))
It throws standard error:
Can't use function return value in write context.
My question is: Why does empty
work on getters and virtual array offsets? As far as I know, they are actually function return values, not variables...
This question is rather educational then practical. I'm just curious. Please try to explain as much as possible.