note 128578 added to function.filter-var
| From: | ajcorrea at gmail dot com | Date: | Thu, 01 Jun 2023 02:32:44 +0000 |
| Subject: | note 128578 added to function.filter-var | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-220534@lists.php.net to get a copy of this message | ||
You can use multiple FLAGS to validate an ip address:
//Validade if input is an IPv4 Address:
$_FILTERS = array('flags' => FILTER_FLAG_IPV4);
//Validade if input is an IPv4 address and isn´t a private IP.
$_FILTERS = array('flags' => FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE);
//Validade if input is an IPv4 and isn´t a reserved IP.
$_FILTERS = array('flags' => FILTER_FLAG_IPV4 | FILTER_FLAG_NO_RES_RANGE);
//Validade if input is an IPv4, isn´t a private IP and isn´t a reserved IP.
$_FILTERS = array('flags' => FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE |
FILTER_FLAG_NO_RES_RANGE);
filter_var($_input, FILTER_VALIDATE_IP, $_FILTERS);
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.13.130 (proxied: 2804:2bf4:252:cafe::1007)
----
Manual Page -- https://php.net/manual/en/function.filter-var.php
Edit -- https://main.php.net/note/edit/128578
Del: integrated -- https://main.php.net/note/delete/128578/integrated
Del: useless -- https://main.php.net/note/delete/128578/useless
Del: bad code -- https://main.php.net/note/delete/128578/bad+code
Del: spam -- https://main.php.net/note/delete/128578/spam
Del: non-english -- https://main.php.net/note/delete/128578/non-english
Del: in docs -- https://main.php.net/note/delete/128578/in+docs
Del: other reasons-- https://main.php.net/note/delete/128578
Reject -- https://main.php.net/note/reject/128578
Search -- https://main.php.net/manage/user-notes.php