Using Arrow Functions In PHP

Snippets 1 min read

Sometimes we need just to make a line in a function or callback and, Arrow Functions in PHP. Came with version 7.4 we can do it easily without the full function.

Instead Of This

Route::get('dashboard', function () {
	return view('dashboard');
});

Do This

 Route::get('/dashboard', fn () => view('dashboard'));

And you are good to go!

For more info check out php documentation


Related Tags

About the Author

Oussama's Profile Picture
Oussama
Full Stack Web Developer

I'm a full stack web developer and telecommunications engineer who love to share knowledge and build stuff online!


Comments

Join Our Newsletter

Subscribe to Our Newsletter and never miss our offers, latest news, Articles, etc.

Our news letter sent once a week, every tuesday.