How to get client IP address in Laravel 5+

前端 未结 18 2716
你的背包
你的背包 2020-11-27 11:11

I am trying to get the client\'s IP address in Laravel.

It is easy to get a client\'s IP in PHP by using $_SERVER[\"REMOTE_ADDR\"]. It is working fine

18条回答
  •  鱼传尺愫
    2020-11-27 12:01

    For Laravel 5 you can use the Request object. Just call its ip() method, something like:

    $request->ip();
    

提交回复
热议问题