【问题标题】:Get previous url in laravel在laravel中获取上一个网址
【发布时间】:2021-11-01 20:37:29
【问题描述】:

我正在尝试在 laravel 中获取以前的 url,我已经尝试过这段代码,

        echo redirect()->back()->getTargetUrl();
        die();

当我简单地回显此代码时,这会正确返回 url,但是当我尝试将其保存在某个变量中时,它不起作用

【问题讨论】:

标签: laravel url redirect back


【解决方案1】:

您可以在文档中找到它。

https://laravel.com/docs/8.x/urls#accessing-the-current-url

// Get the current URL without the query string...
echo url()->current();

// Get the current URL including the query string...
echo url()->full();

// Get the full URL for the previous request...
echo url()->previous();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-09-30
    • 1970-01-01
    • 1970-01-01
    • 2017-11-22
    • 1970-01-01
    • 2014-02-25
    • 1970-01-01
    • 2019-07-22
    相关资源
    最近更新 更多