From the course: Functional Programming with PHP
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Arrow functions in PHP - PHP Tutorial
From the course: Functional Programming with PHP
Arrow functions in PHP
- [Instructor] So far, we've seen that we can assign functions to variables, pass them as arguments to other functions, and return them from functions. And this provides us, as we've already seen and will continue to see, with some great benefits over the old inflexible way that procedural and object oriented programming tend to treat functions. However, as one might expect, it also drastically increases the use of functions across our code base. And because of this increase, especially in cases where the body of our functions are only one line, it'd be nice for us to have a more compacted version of defining functions than using the function keyword, the return keyword, and when we need to use closure for some variables, the use keyword. Well as it happens, PHP does provide us with a different, more compact syntax for defining smaller functions. And this is something called arrow functions, and they're also called short…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.