Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mosesnagar's avatar

back() vs redirect()->back()

hi, whats the different between using back() and redirect()->back() ? both have the same result for me

0 likes
6 replies
bobbybouwmann's avatar
Level 88

@mosesnagar back() is just a helper function. It's doing the same thing for you ;)

These are all the same

return back();

return redirect()->back();

return redirect()->previous();

You can find the helper function in vendor/laravel/framework/src/Illuminate/Foundation/helpers.php around line 153, for Laravel 5.2.

7 likes
dannydjones's avatar

@mosesnagar Its simply to offer choice, people have lots of different preferences in how they code, laravel tries to give you lots of ways of doing the same thing so you can do it however you like best.

In some cases I prefer to be much more verbose in my code instead of using helper functions, having the options means I can easily trade out for whatever I think works best at the time :)

RoboRobok's avatar

It's mostly a matter of making popular methods accessible without importing. For me it's discussable whether global functions are good or bad design, but one is for sure: they are extremely convenient.

jmatike's avatar

Hello, 2 years later, may I know how to use the same helper in the view/blade file ?

Please or to participate in this conversation.