valid_ip($ip[, $which = ''])
| Parameters: |
|
|---|---|
| Returns: |
TRUE if the address is valid, FALSE if not |
| Return type: |
bool |
Takes an IP address as input and returns TRUE or FALSE (boolean) depending on whether it is valid or not.
Note
The $this->input->ip_address() method above automatically validates the IP address.
if ( ! $this->input->valid_ip($ip))
{
echo 'Not Valid';
}
else
{
echo 'Valid';
}
Accepts an optional second string parameter of ‘ipv4’ or ‘ipv6’ to specify an IP format. The default checks for both formats.
Please login to continue.