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!

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

PHP PHP Functions Function Returns and More PHP Closures

4 Answers

Nope :)

I'm not sure but I think there is. In the first example you set the variable $greet to be the specified function. In the second example you simply create a function greet().

In the case of the first example where you set it as a variable, you can later (or earlier in your code) change that variable to be something completely different than the function. Such as for example, another function or a new integer, etc.

In the second example there is no variable, only a set function called greet() which can not be changed unless you change the code of the function itself.

That is one difference...

What do you mean?

Moses Finlay
.a{fill-rule:evenodd;}techdegree seal-36
Moses Finlay
Full Stack JavaScript Techdegree Graduate 24,800 Points
$greet = function() {


Starts off with a variable, then the function ends with the a semicolon. Is there a different way to call

$greet = function() {
    echo '?';