Getting the IP address using PHP
You can display the visitor's IP address on a webpage or you can use it for other purposes such as storing it for security (if you're running an e-commerce site), redirecting the visitor, even banning the visitor from your website if you need to.
Get IP address of a visitor
Use the REMOTE_ADDR index of the $_SERVER array to get the IP address of the visitor.
Get IP address of a website
You can get the IP address of a website by it's URL. Include the URL as a parameter of the gethostbyname() function.