Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
How does a function can be called without set of ()
I am confused over how do we call on a function without set of () , in the video the call to function is done by
$func = answer;
echo $func ;
Whereas i what i know is that a function is called like
$func = answer();
So why is the video other way around without ()
In the second version the parenthesis are kind of included in the $func variable. So after that it's possible to call it without them, because what you are actually calling when you write
Hugo Paz15,622 Points
If you notice in the video, he uses parenthesis on the variable, like this:
$func = 'answer';