File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -133,8 +133,11 @@ string(21) "SomeClass::someMethod"
133
133
<example >
134
134
<title ><function >is_callable</function > and constructors</title >
135
135
<simpara >
136
- <function >is_callable</function > reports constructors as
137
- not being callable.
136
+ Despite the fact that constructors are the methods that are called when
137
+ an object is created, they are not static methods and
138
+ <function >is_callable</function > will return &false; for them. It's not
139
+ possible to use <function >is_callable</function > to check if a class can
140
+ be instantiated from the current scope.
138
141
</simpara >
139
142
<programlisting role =" php" >
140
143
<![CDATA[
@@ -152,6 +155,9 @@ var_dump(
152
155
is_callable(['Foo', 'foo'])
153
156
);
154
157
158
+ $foo = new Foo();
159
+ var_dump(is_callable([$foo, '__construct']));
160
+
155
161
?>
156
162
]]>
157
163
</programlisting >
@@ -160,6 +166,7 @@ var_dump(
160
166
<![CDATA[
161
167
bool(false)
162
168
bool(false)
169
+ bool(true)
163
170
]]>
164
171
</screen >
165
172
</example >
You can’t perform that action at this time.
0 commit comments