Get user IP address in PHP, while users open web server:
PHP: get IP address in PHP, from your web server. PHP HTTP_CLIENT_IP and display client IP address and if you want you can store the IP address using PHP programming language.
When a users open your web application or log in your web page, then you can store the user system IP address and store in the database table field. So you’ll get information from the users to open your application.
You can count how many IP addresses connect your application. So let’s go to the example, if you want to try is so, create an index.php page in your local or online server and move the example code and get the result.
Example:
<?php if (!empty($_SERVER['HTTP_CLIENT_IP'])) { echo $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { echo $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { echo $ip = $_SERVER['REMOTE_ADDR']; } ?>
Related posts