Arrow function in PHP 7.4

PHP 7.4

Arrow functions, introduced in PHP 7.4, provides a concise way to write functions in PHP 7.4. Short closures, also called Arrow functions, are a way of writing shorter functions in PHP 7.4.

This notation is useful when passing closures to functions like array_map or array_filter.

Arrow functions can be used:

  • Available as of PHP 7.4
  • No return keyword allowed
  • Have one expression, which is the return statement
  • Start with the fn keyword

Here are some examples, so you can differentiate Arrow function:

1) array_map function

Current

Using Arrow function

Kindly checkout below blog to get more example about Arrow function:

https://codeshipguru.blogspot.com/2019/10/arrow-function-in-php-74.html

Thank you!!!

I enjoy using my obsessive attention to detail, my unequivocal love for making things, and my mission-driven work ethic to literally change the World.

I enjoy using my obsessive attention to detail, my unequivocal love for making things, and my mission-driven work ethic to literally change the World.