Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ServerAddress.php
Go to the documentation of this file.
1 <?php
7 
9 
14 {
20  protected $request;
21 
25  public function __construct(RequestInterface $httpRequest)
26  {
27  $this->request = $httpRequest;
28  }
29 
36  public function getServerAddress($ipToLong = false)
37  {
38  $address = $this->request->getServer('SERVER_ADDR');
39  if (!$address) {
40  return false;
41  }
42  return $ipToLong ? ip2long($address) : $address;
43  }
44 }
$address
Definition: customer.php:38