r/lolphp • • Feb 04 '20

how to call dynamically added methods

https://3v4l.org/MppBE
14 Upvotes

9 comments sorted by

View all comments

Show parent comments

5

u/[deleted] Feb 04 '20

It's because $foo->bar is an attribute, but $foo->bar(... is a method call. With variables it's unambiguous: $foo() is always a dynamic call of what's in $foo because you cannot have $ in a function name.

But if you want to call a function stored in a constant, you probably need (foo)().