What is the common method to capture a user's IP address in PHP?

To capture a user's IP address in PHP, you can use the $_SERVER superglobal variable with the key 'REMOTE_ADDR'. This will give you the IP address of the user accessing your website. You can store this IP address in a variable for further processing or logging.

$user_ip = $_SERVER['REMOTE_ADDR'];
echo "User's IP address: " . $user_ip;