![]() ![]() | ![]() |
1.1 misho 1: --TEST--
2: Test is_a() function : usage variations - wrong type for arg 2
3: --INI--
4: error_reporting=E_ALL | E_STRICT | E_DEPRECATED
5: --FILE--
6: <?php
7: /* Prototype : proto bool is_a(object object, string class_name)
8: * Description: Returns true if the object is of this class or has this class as one of its parents
9: * Source code: Zend/zend_builtin_functions.c
10: * Alias to functions:
11: */
12:
13: class C {
14: function __toString() {
15: return "C Instance";
16: }
17: }
18:
19: echo "*** Testing is_a() : usage variations ***\n";
20:
21: // Initialise function arguments not being substituted (if any)
22: $object = new stdclass();
23:
24: //get an unset variable
25: $unset_var = 10;
26: unset ($unset_var);
27:
28: //array of values to iterate over
29: $values = array(
30:
31: // int data
32: 0,
33: 1,
34: 12345,
35: -2345,
36:
37: // float data
38: 10.5,
39: -10.5,
40: 10.1234567e10,
41: 10.7654321E-10,
42: .5,
43:
44: // array data
45: array(),
46: array(0),
47: array(1),
48: array(1, 2),
49: array('color' => 'red', 'item' => 'pen'),
50:
51: // null data
52: NULL,
53: null,
54:
55: // boolean data
56: true,
57: false,
58: TRUE,
59: FALSE,
60:
61: // empty data
62: "",
63: '',
64:
65: // object data
66: new C,
67:
68: // undefined data
69: $undefined_var,
70:
71: // unset data
72: $unset_var,
73: );
74:
75: // loop through each element of the array for class_name
76:
77: foreach($values as $value) {
1.1.1.2 ! misho 78: echo @"\nArg value $value \n";
1.1 misho 79: var_dump( is_a($object, $value) );
80: };
81:
82: echo "Done";
83: ?>
84: --EXPECTF--
85: *** Testing is_a() : usage variations ***
86:
87: Notice: Undefined variable: undefined_var in %s on line 64
88:
89: Notice: Undefined variable: unset_var in %s on line 67
90:
91: Arg value 0
92: bool(false)
93:
94: Arg value 1
95: bool(false)
96:
97: Arg value 12345
98: bool(false)
99:
100: Arg value -2345
101: bool(false)
102:
103: Arg value 10.5
104: bool(false)
105:
106: Arg value -10.5
107: bool(false)
108:
109: Arg value 101234567000
110: bool(false)
111:
112: Arg value 1.07654321E-9
113: bool(false)
114:
115: Arg value 0.5
116: bool(false)
117:
118: Arg value Array
119:
120: Warning: is_a() expects parameter 2 to be string, array given in %s on line %d
121: NULL
122:
123: Arg value Array
124:
125: Warning: is_a() expects parameter 2 to be string, array given in %s on line %d
126: NULL
127:
128: Arg value Array
129:
130: Warning: is_a() expects parameter 2 to be string, array given in %s on line %d
131: NULL
132:
133: Arg value Array
134:
135: Warning: is_a() expects parameter 2 to be string, array given in %s on line %d
136: NULL
137:
138: Arg value Array
139:
140: Warning: is_a() expects parameter 2 to be string, array given in %s on line %d
141: NULL
142:
143: Arg value
144: bool(false)
145:
146: Arg value
147: bool(false)
148:
149: Arg value 1
150: bool(false)
151:
152: Arg value
153: bool(false)
154:
155: Arg value 1
156: bool(false)
157:
158: Arg value
159: bool(false)
160:
161: Arg value
162: bool(false)
163:
164: Arg value
165: bool(false)
166:
167: Arg value C Instance
168: bool(false)
169:
170: Arg value
171: bool(false)
172:
173: Arg value
174: bool(false)
175: Done