Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Laravel Basics!
You have completed Laravel Basics!
Closures are anonymous functions that don’t belong to any class or object. Closures don’t have specified names and can also access variables outside of scope without using any global variables. Closures require less code and are simpler to write, which makes them handy tools when creating simple functions, like the About response we created in the last section. You'll use closures frequently when creating routes, so what is a Closure, exactly? PHP code can execute inside of Closures, much like functions do-- for example, you can work with variables and perform math operations within a closure that’s defined within a route. That’s a mouthful, but it’s simple-- routes can execute code using Closures, which are simply anonymous functions.
LINKS:
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up