$ip = "192.168.1.1"; if(isIP($ip)){ echo "$ip is a valid IP address."; } else { echo "$ip is not a valid IP address."; }
$ip = $_SERVER['REMOTE_ADDR']; if(isIP($ip)){ echo "Welcome from $ip!"; } else { echo "Invalid IP address."; }This example checks the IP address of the user visiting the website using the `$_SERVER['REMOTE_ADDR']` variable and then validates it using the isIP() function. If the IP address is valid, it greets the user with a welcome message. The isIP() function is built-in in PHP, so no package library is required.