2
ReflectionClass::getProperty()
4
Robin Fernandes <robinf@php.net>
5
Steve Seear <stevseea@php.net>
12
class subpubf extends pubf {
19
class subprotf extends protf {
26
class subprivf extends privf {
29
$classes = array("pubf", "subpubf", "protf", "subprotf",
31
foreach($classes as $class) {
32
echo "Reflecting on class $class: \n";
33
$rc = new ReflectionClass($class);
35
echo " --> Check for s: ";
36
var_dump($rc->getProperty("s"));
37
} catch (exception $e) {
38
echo $e->getMessage() . "\n";
41
echo " --> Check for a: ";
42
var_dump($rc->getProperty("a"));
43
} catch (exception $e) {
44
echo $e->getMessage() . "\n";
47
echo " --> Check for A: ";
48
var_dump($rc->getProperty("A"));
49
} catch (exception $e) {
50
echo $e->getMessage() . "\n";
53
echo " --> Check for doesntExist: ";
54
var_dump($rc->getProperty("doesntExist"));
55
} catch (exception $e) {
56
echo $e->getMessage() . "\n";
62
Reflecting on class pubf:
63
--> Check for s: object(ReflectionProperty)#%d (2) {
65
%unicode|string%(1) "s"
67
%unicode|string%(4) "pubf"
69
--> Check for a: object(ReflectionProperty)#%d (2) {
71
%unicode|string%(1) "a"
73
%unicode|string%(4) "pubf"
75
--> Check for A: Property A does not exist
76
--> Check for doesntExist: Property doesntExist does not exist
77
Reflecting on class subpubf:
78
--> Check for s: object(ReflectionProperty)#%d (2) {
80
%unicode|string%(1) "s"
82
%unicode|string%(4) "pubf"
84
--> Check for a: object(ReflectionProperty)#%d (2) {
86
%unicode|string%(1) "a"
88
%unicode|string%(4) "pubf"
90
--> Check for A: Property A does not exist
91
--> Check for doesntExist: Property doesntExist does not exist
92
Reflecting on class protf:
93
--> Check for s: object(ReflectionProperty)#%d (2) {
95
%unicode|string%(1) "s"
97
%unicode|string%(5) "protf"
99
--> Check for a: object(ReflectionProperty)#%d (2) {
101
%unicode|string%(1) "a"
103
%unicode|string%(5) "protf"
105
--> Check for A: Property A does not exist
106
--> Check for doesntExist: Property doesntExist does not exist
107
Reflecting on class subprotf:
108
--> Check for s: object(ReflectionProperty)#%d (2) {
110
%unicode|string%(1) "s"
112
%unicode|string%(5) "protf"
114
--> Check for a: object(ReflectionProperty)#%d (2) {
116
%unicode|string%(1) "a"
118
%unicode|string%(5) "protf"
120
--> Check for A: Property A does not exist
121
--> Check for doesntExist: Property doesntExist does not exist
122
Reflecting on class privf:
123
--> Check for s: object(ReflectionProperty)#%d (2) {
125
%unicode|string%(1) "s"
127
%unicode|string%(5) "privf"
129
--> Check for a: object(ReflectionProperty)#%d (2) {
131
%unicode|string%(1) "a"
133
%unicode|string%(5) "privf"
135
--> Check for A: Property A does not exist
136
--> Check for doesntExist: Property doesntExist does not exist
137
Reflecting on class subprivf:
138
--> Check for s: object(ReflectionProperty)#%d (2) {
140
%unicode|string%(1) "s"
142
%unicode|string%(5) "privf"
144
--> Check for a: Property a does not exist
145
--> Check for A: Property A does not exist
146
--> Check for doesntExist: Property doesntExist does not exist