dtpw54085 2018-11-25 10:47
浏览 503

在laravel中获得REFERRER

I'm a newbie in laravel, so maybe please don't beat me :-)

I try to get the referrer inside a controller in this way

$from=Request::server('HTTP_REFERER');

As result, I get this error

Non-static method Illuminate\Http\Request::server() should not be called statically, assuming $this from incompatible context

At the top from the controller is

namespace Common\Auth\Controllers;

use Auth;
use Illuminate\Http\Request;
use Common\Settings\Settings;
use Common\Core\Controller;
use Common\Core\BootstrapData;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Common\Auth\User;

Hope somebody can show me how I can get the referrer a give me a little lesson about that.

Thanks a lot.

Update.

In the meantime i've add "function name(Request $request)" to my function and inside the function "$this->request = $request;"

Now i can access with "$this->request->ip();" some informations.

If i try to echo that "$this->request->header('HTTP_REFERRER')" nothing will display?

  • 写回答

1条回答 默认 最新

  • dongqiao1888 2018-11-25 11:38
    关注

    I dont know why laravel request facade not working like above, but you can get header like this

    function example(Request $request) {
        dd($request->header('HTTP_REFERRER'));
    }
    

    make sure your method accessed from route

    评论

报告相同问题?

悬赏问题

  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错