1var_dump(filter_var('bob@example.com', FILTER_VALIDATE_EMAIL));
2var_dump(filter_var('http://example.com', FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED));
3
1
2 <?php
3$ip = "2001:0db8:85a3:08d3:1319:8a2e:0370:7334";
4
5if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === false) {
6 echo("$ip is a valid IPv6 address");
7} else {
8
9 echo("$ip is not a valid IPv6 address");
10}
11?>
12
1
2 <?php
3$int = 122;
4$min = 1;
5$max = 200;
6
7if (filter_var($int, FILTER_VALIDATE_INT, array("options" => array("min_range"=>$min, "max_range"=>$max))) === false) {
8 echo("Variable value is not within the legal range");
9} else {
10 echo("Variable value is within the legal range");
11}
12?>
13