My current IP is : 24.62.137.161
and when I use
$ip = $request->getClientIp();
dd($ip);
I keep getting ::1
How can I grab 24.62.137.161
?
I'm not sure if what I'm trying to do if possible.
Any hints / suggestion will be much appreciated.
For getting the IP Address we have to include use Illuminate\Http\Request; in the controller and then add the code of the below pre tag. It will give the IP address of the network. dd($request->ip()); }$clientIP = \Request::ip();
The simplest way to collect the visitor IP address in PHP is the REMOTE_ADDR. Pass the 'REMOTE_ADDR' in PHP $_SERVER variable. It will return the IP address of the visitor who is currently viewing the webpage.
You can use request object: request()->server('SERVER_ADDR'); Or you can use standard PHP way: $_SERVER['SERVER_ADDR'];
$_SERVER['REMOTE_ADDR'] Returns the IP address from where the user is viewing the current page. $_SERVER['REMOTE_HOST'] Returns the Host name from where the user is viewing the current page. $_SERVER['REMOTE_PORT']
$ip = trim(shell_exec("dig +short myip.opendns.com @resolver1.opendns.com"));
dd("Public IP: ".$ip); //"Public IP: 24.62.137.161"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With