reference/filter/examples.xml
247c617b3d54ac8b8fcd8d82516a476c751ddafd
...
...
@@ -16,10 +16,12 @@ $email_a = 'joe@example.com';
16
16
$email_b = 'bogus';
17
17

18
18
if (filter_var($email_a, FILTER_VALIDATE_EMAIL)) {
19
-
echo "This ($email_a) email address is considered valid.";
19
+
echo "Email address '$email_a' is considered valid.\n";
20
20
}
21
21
if (filter_var($email_b, FILTER_VALIDATE_EMAIL)) {
22
-
echo "This ($email_b) email address is considered valid.";
22
+
echo "Email address '$email_b' is considered valid.\n";
23
+
} else {
24
+
echo "Email address '$email_b' is considered invalid.\n";
23
25
}
24
26
?>
25
27
]]>
...
...
@@ -27,7 +29,8 @@ if (filter_var($email_b, FILTER_VALIDATE_EMAIL)) {
27
29
&example.outputs;
28
30
<screen>
29
31
<![CDATA[
30
-
This (joe@example.com) email address is considered valid.
32
+
Email address 'joe@example.com' is considered valid.
33
+
Email address 'bogus' is considered invalid.
31
34
]]>
32
35
</screen>
33
36
</example>
...
...
@@ -43,10 +46,10 @@ $ip_a = '127.0.0.1';
43
46
$ip_b = '42.42';
44
47

45
48
if (filter_var($ip_a, FILTER_VALIDATE_IP)) {
46
-
echo "This (ip_a) IP address is considered valid.";
49
+
echo "IP address '$ip_a' is considered valid.";
47
50
}
48
51
if (filter_var($ip_b, FILTER_VALIDATE_IP)) {
49
-
echo "This (ip_b) IP address is considered valid.";
52
+
echo "IP address '$ip_b' is considered valid.";
50
53
}
51
54
?>
52
55
]]>
...
...
@@ -54,7 +57,7 @@ if (filter_var($ip_b, FILTER_VALIDATE_IP)) {
54
57
&example.outputs;
55
58
<screen>
56
59
<![CDATA[
57
-
This (ip_a) IP address is considered valid.
60
+
IP address '127.0.0.1' is considered valid.
58
61
]]>
59
62
</screen>
60
63
</example>
...
...
@@ -71,23 +74,23 @@ $int_b = '-1';
71
74
$int_c = '4';
72
75
$options = array(
73
76
'options' => array(
74
-
'min_range' => 0,
75
-
'max_range' => 3,
76
-
)
77
+
'min_range' => 0,
78
+
'max_range' => 3,
79
+
)
77
80
);
78
81
if (filter_var($int_a, FILTER_VALIDATE_INT, $options) !== FALSE) {
79
-
echo "This (int_a) integer is considered valid (between 0 and 3).\n";
82
+
echo "Integer A '$int_a' is considered valid (between 0 and 3).\n";
80
83
}
81
84
if (filter_var($int_b, FILTER_VALIDATE_INT, $options) !== FALSE) {
82
-
echo "This (int_b) integer is considered valid (between 0 and 3).\n";
85
+
echo "Integer B '$int_b' is considered valid (between 0 and 3).\n";
83
86
}
84
87
if (filter_var($int_c, FILTER_VALIDATE_INT, $options) !== FALSE) {
85
-
echo "This (int_c) integer is considered valid (between 0 and 3).\n";
88
+
echo "Integer C '$int_c' is considered valid (between 0 and 3).\n";
86
89
}
87
90

88
91
$options['options']['default'] = 1;
89
92
if (($int_c = filter_var($int_c, FILTER_VALIDATE_INT, $options)) !== FALSE) {
90
-
echo "This (int_c) integer is considered valid (between 0 and 3) and is $int_c.";
93
+
echo "Integer C '$int_c' is considered valid (between 0 and 3).";
91
94
}
92
95
?>
93
96
]]>
...
...
@@ -95,8 +98,8 @@ if (($int_c = filter_var($int_c, FILTER_VALIDATE_INT, $options)) !== FALSE) {
95
98
&example.outputs;
96
99
<screen>
97
100
<![CDATA[
98
-
This (int_a) integer is considered valid (between 0 and 3).
99
-
This (int_c) integer is considered valid (between 0 and 3) and is 1.
101
+
Integer A '1' is considered valid (between 0 and 3).
102
+
Integer C '1' is considered valid (between 0 and 3).
100
103
]]>
101
104
</screen>
102
105
</example>
103
106