xref: /PHP-5.5/Zend/tests/011.phpt (revision 9c787d8c)
1--TEST--
2property_exists() tests
3--FILE--
4<?php
5
6class foo {
7	public $pp1 = 1;
8	private $pp2 = 2;
9	protected $pp3 = 3;
10
11	function bar() {
12		var_dump(property_exists("foo","pp1"));
13		var_dump(property_exists("foo","pp2"));
14		var_dump(property_exists("foo","pp3"));
15	}
16}
17
18class bar extends foo {
19	function test() {
20		var_dump(property_exists("foo","pp1"));
21		var_dump(property_exists("foo","pp2"));
22		var_dump(property_exists("foo","pp3"));
23	}
24}
25
26var_dump(property_exists());
27var_dump(property_exists(""));
28var_dump(property_exists("foo","pp1"));
29var_dump(property_exists("foo","pp2"));
30var_dump(property_exists("foo","pp3"));
31var_dump(property_exists("foo","nonexistent"));
32var_dump(property_exists("fo","nonexistent"));
33var_dump(property_exists("foo",""));
34var_dump(property_exists("","test"));
35var_dump(property_exists("",""));
36
37$foo = new foo;
38
39var_dump(property_exists($foo,"pp1"));
40var_dump(property_exists($foo,"pp2"));
41var_dump(property_exists($foo,"pp3"));
42var_dump(property_exists($foo,"nonexistent"));
43var_dump(property_exists($foo,""));
44var_dump(property_exists(array(),"test"));
45var_dump(property_exists(1,"test"));
46var_dump(property_exists(true,"test"));
47
48$foo->bar();
49
50$bar = new bar;
51$bar->test();
52
53echo "Done\n";
54?>
55--EXPECTF--
56Warning: property_exists() expects exactly 2 parameters, 0 given in %s on line %d
57NULL
58
59Warning: property_exists() expects exactly 2 parameters, 1 given in %s on line %d
60NULL
61bool(true)
62bool(true)
63bool(true)
64bool(false)
65bool(false)
66bool(false)
67bool(false)
68bool(false)
69bool(true)
70bool(true)
71bool(true)
72bool(false)
73bool(false)
74
75Warning: First parameter must either be an object or the name of an existing class in %s on line %d
76NULL
77
78Warning: First parameter must either be an object or the name of an existing class in %s on line %d
79NULL
80
81Warning: First parameter must either be an object or the name of an existing class in %s on line %d
82NULL
83bool(true)
84bool(true)
85bool(true)
86bool(true)
87bool(true)
88bool(true)
89Done
90