有没有办法通过这个 PHP 表单获取客户端 IP 地址

is there a way to get clients IP addresses through this PHP form

有没有办法通过这个 PHP 表格获取客户端的 IP 地址,或者有人可以在这里提供正确的获取 IP 地址的方法。

<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

require_once './vendor/autoload.php';

use FormGuide\Handlx\FormHandler;


$pp = new FormHandler(); 

$validator = $pp->getValidator();
$validator->fields(['name','phone','email'])->areRequired()->maxLength(50);
$validator->field('email')->isEmail();
$validator->field('message')->maxLength(6000);
$validator->field('countryCode')->maxLength(20);
$validator->field('phone')->maxLength(20);


$pp->requireCaptcha();

 
$pp = getIPAddress($_SERVER['REMOTE_ADDR']);  



$pp->sendEmailTo('someone@mail.com'); 

echo $pp->process($_POST);

试试这个

<?php

    function getRealIP(){

        if (isset($_SERVER["HTTP_CLIENT_IP"])){

            return $_SERVER["HTTP_CLIENT_IP"];

        }elseif (isset($_SERVER["HTTP_X_FORWARDED_FOR"])){

            return $_SERVER["HTTP_X_FORWARDED_FOR"];

        }elseif (isset($_SERVER["HTTP_X_FORWARDED"])){

            return $_SERVER["HTTP_X_FORWARDED"];

        }elseif (isset($_SERVER["HTTP_FORWARDED_FOR"])){

            return $_SERVER["HTTP_FORWARDED_FOR"];

        }elseif (isset($_SERVER["HTTP_FORWARDED"])){

            return $_SERVER["HTTP_FORWARDED"];

        }else{

            return $_SERVER["REMOTE_ADDR"];

        }
    }       
?>