using php, how validate string valid ip?
examples of valid strings:
- 192.158.5.95
- 121.212
- 12.12.12.204
examples of invalid strings:
- 121
- 10 12 12 (no dots)
my current script uses code, insufficient needs:
if(strpos($input, '.') !== false) { // there period } else { // no period }
as such, can please advise how can validate string valid ip?
$valid = ip2long($ip) !== false;
Comments
Post a Comment