xref: /php-src/ext/filter/tests/061.phpt (revision 74859783)
1--TEST--
2filter_var() and FILTER_VALIDATE_BOOL
3--EXTENSIONS--
4filter
5--FILE--
6<?php
7
8class test {
9
10    function __toString() {
11        return "blah";
12    }
13}
14
15$t = new test;
16
17var_dump(filter_var("no", FILTER_VALIDATE_BOOL));
18var_dump(filter_var(NULL, FILTER_VALIDATE_BOOL));
19var_dump(filter_var($t, FILTER_VALIDATE_BOOL));
20var_dump(filter_var(array(1,2,3,0,array("", "123")), FILTER_VALIDATE_BOOL, FILTER_REQUIRE_ARRAY));
21var_dump(filter_var("yes", FILTER_VALIDATE_BOOL));
22var_dump(filter_var("true", FILTER_VALIDATE_BOOL));
23var_dump(filter_var("false", FILTER_VALIDATE_BOOL));
24var_dump(filter_var("off", FILTER_VALIDATE_BOOL));
25var_dump(filter_var("on", FILTER_VALIDATE_BOOL));
26var_dump(filter_var("0", FILTER_VALIDATE_BOOL));
27var_dump(filter_var("1", FILTER_VALIDATE_BOOL));
28var_dump(filter_var("NONE", FILTER_VALIDATE_BOOL));
29var_dump(filter_var("", FILTER_VALIDATE_BOOL));
30var_dump(filter_var(-1, FILTER_VALIDATE_BOOL));
31var_dump(filter_var("000000", FILTER_VALIDATE_BOOL));
32var_dump(filter_var("111111", FILTER_VALIDATE_BOOL));
33
34
35echo "Done\n";
36?>
37--EXPECT--
38bool(false)
39bool(false)
40bool(false)
41array(5) {
42  [0]=>
43  bool(true)
44  [1]=>
45  bool(false)
46  [2]=>
47  bool(false)
48  [3]=>
49  bool(false)
50  [4]=>
51  array(2) {
52    [0]=>
53    bool(false)
54    [1]=>
55    bool(false)
56  }
57}
58bool(true)
59bool(true)
60bool(false)
61bool(false)
62bool(true)
63bool(false)
64bool(true)
65bool(false)
66bool(false)
67bool(false)
68bool(false)
69bool(false)
70Done
71