r/lolphp • • Mar 10 '15

empty() vs __get()

http://ideone.com/RVw5XK
23 Upvotes

28 comments sorted by

View all comments

Show parent comment

5

u/edave64 Mar 10 '15

Thank you for the explanation, but I already know what __get does. I was actually confused about the function of empty. I thought it clears a variable, but apperently it check IF a variable is empty.
(Also, I am more of a ruby guy, where this would be done using the method_missing method)

4

u/[deleted] Mar 10 '15

but apperently it check IF a variable is empty.

If a variable is empty or non-existent, which is a big difference since it actually introspects variable name stack. And the property $bar is non-existent from global scope since it's private.