-
Notifications
You must be signed in to change notification settings - Fork 0
validIP
Corey Avis edited this page Sep 23, 2026
·
2 revisions
Validates IPv4 and IPv6 addresses.
validIP(string $ip, string &$version): bool
ip (string) : IPv4 or IPv6 address to validate.
version (string) : If version is populated, then it returns the detected IP standard (IPv4 or IPv6) upon successful validation. ^(optional)^
(bool)
: Returns true on success and false on failure.
$cphp->validIP('127.0.0.1') = true
$cphp->validIP('1.2.3') = false
$cphp->validIP('fd00::a:b:c:d') = true
$cphp->validIP('2001:db8:1:2:3:4:5') = false
| IP address [^1] | Valid [^2] | $version [^3] |
|---|---|---|
| 192.168.1.1 | true | IPv4 |
| fe80::1 | true | IPv6 |
[^1]: The supplied IP address
[^2]: true if valid, false if invalid
[^3]: The detected IP standard (IPv4 or IPv6)
- Logs a notice if IP address is empty.
- Logs a notice if invalid IP address format.