This article mainly introduces php's method of determining the IP address to be accessed. It involves php's judgment and usage skills on the SERVER's predefined variable $ _ SERVER. For more information, see
This article mainly introduces php's method of determining the IP address to be accessed. It involves php's judgment and usage skills on the SERVER's predefined variable $ _ SERVER. For more information, see
This example describes how to use php to determine the IP address to access. Share it with you for your reference. The details are as follows:
<? Php function getIP () {if (! Empty ($ _ SERVER ["HTTP_CLIENT_IP"]) {$ cip = $ _ SERVER ["HTTP_CLIENT_IP"];} else if (! Empty ($ _ SERVER ["HTTP_X_FORWARDED_FOR"]) {$ cip = $ _ SERVER ["HTTP_X_FORWARDED_FOR"];} else if (! Empty ($ _ SERVER ["REMOTE_ADDR"]) {$ cip = $ _ SERVER ["REMOTE_ADDR"] ;}else {$ cip = '';} preg_match ("/[\ d \.] {7, 15}/", $ cip, $ cips); $ cip = isset ($ cips [0])? $ Cips [0]: 'unknown '; unset ($ cips); return $ cip;}?>
I hope this article will help you with php programming.
,