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

PHP

Incorrect Answer given in PHP Basics Test

I believe the answer to a question on the PHP Basics course to be incorrect:

PHP Basics

Function Returns and More (Section 2)

PHP Closures (Step 3)

Quiz Question (What is the correct way to pass an argument to a variable function?)

It says the answer to this question is:

'$func('Mike');'

but the course doesn't teach this. The course teaches answer:

'$name = 'Mike'; $func() use $name;'

Can you please confirm for me which is correct?

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi, Charlie George ! The answer $func('Mike') is indeed correct. I believe you're confusing variable functions with closures which are different.

I might recommend checking out around 1:55 of this video where this technique is used.

Hope this helps! :sparkles:

Ahhh, I see. So the test is based on all videos, not just the Closures videos! My bad! Usually the test only has questions catered towards the immediately previous content whereas this one obviously is referencing content a bit further back. Thanks for clarifying, Jennifer :-)