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
Loading...
Related Quiz
- To execute a query in a MySQL database using PHP, you can use the mysqli_query function like $result = mysqli_query($conn, ______);.
- In PHP, an array can only hold values of the same data type.
- Which of the following are common uses of arrays in PHP?
- How do you handle errors when using output control functions in PHP?
- Which of the following are common uses of the $_POST superglobal in PHP?