src/http/request/Client.php
public function getIp(): string
    {
        if ($this->ip === null) {
            foreach (["HTTP_X_FORWARDED_FOR", "X_FORWARDED_FOR"] as $key) {
                $proxyIpList = $this->environment[$key] ?? "";
                if ($proxyIpList) {
                    $commaPosition = strpos($proxyIpList, ",");
                    if ($commaPosition !== false) {
                        $this->ip = substr($proxyIpList, 0, $commaPosition);
                    } else {
                        $this->ip = $proxyIpList;
                    }
                    return $this->ip;
                }
            }
            $this->ip = $this->environment["REMOTE_ADDR"] ?? "";
        }
        return $this->ip;
    }
public function getIp(): string
    {
        if ($this->ip === null) {
            foreach (["HTTP_X_FORWARDED_FOR", "X_FORWARDED_FOR"] as $key) {
                $proxyIpList = $this->environment[$key] ?? "";
                if ($proxyIpList) {
                    $commaPosition = strpos($proxyIpList, ",");
                    if ($commaPosition !== false) {
                        $this->ip = substr($proxyIpList, 0, $commaPosition);
                    } else {
                        $this->ip = $proxyIpList;
                    }
                    return $this->ip;
                }
            }
            $this->ip = $this->environment["REMOTE_ADDR"] ?? "";
        }
        return $this->ip;
    }
public function getIp ( ) : string { if ( $ this -> ip === null ) { foreach ( [ "HTTP_X_FORWARDED_FOR" , "X_FORWARDED_FOR" ] as $ key ) { $ proxyIpList = $ this -> environment [ $ key ] ?? "" ; if ( $ proxyIpList ) { $ commaPosition = strpos ( $ proxyIpList , "," ) ; if ( $ commaPosition !== false ) { $ this -> ip = substr ( $ proxyIpList , 0 , $ commaPosition ) ; } else { $ this -> ip = $ proxyIpList ; } return $ this -> ip ; } } $ this -> ip = $ this -> environment [ "REMOTE_ADDR" ] ?? "" ; } return $ this -> ip ; }
Retrieve the client ip address

@return string
Retrieve the client ip address