You are writing a PHP script and you need to access the user's IP address. How would you do this using the $_SERVER superglobal?

  • $_SERVER['REMOTE_ADDR']
  • $_SERVER['USER_IP']
  • $_SERVER['CLIENT_IP']
  • $_SERVER['VISITOR_IP']
To access the user's IP address using the $_SERVER superglobal in PHP, you can use $_SERVER['REMOTE_ADDR']. This key retrieves the IP address of the client who accessed the current script. The IP address can be useful for various purposes, such as logging, security, geolocation, or personalization. By accessing the 'REMOTE_ADDR' key within the $_SERVER superglobal, you can retrieve the client's IP address. Learn more: https://www.php.net/manual/en/reserved.variables.server.php
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *