Skip to content

Commit eb55709

Browse files
authored
isinstance.xml Make the example workable and semantic (php#4903)
1 parent 18bac83 commit eb55709

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

reference/reflection/reflectionclass/isinstance.xml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,24 @@
4848
<programlisting role="php">
4949
<![CDATA[
5050
<?php
51-
// Example usage
52-
$class = new ReflectionClass('Foo');
5351
54-
if ($class->isInstance($arg)) {
55-
echo "Yes";
52+
class Foo {}
53+
54+
$object = new Foo();
55+
56+
$reflection = new ReflectionClass('Foo');
57+
58+
if ($reflection->isInstance($object)) {
59+
echo "Yes\n";
5660
}
5761
5862
// Equivalent to
59-
if ($arg instanceof Foo) {
60-
echo "Yes";
63+
if ($object instanceof Foo) {
64+
echo "Yes\n";
6165
}
6266
6367
// Equivalent to
64-
if (is_a($arg, 'Foo')) {
68+
if (is_a($object, 'Foo')) {
6569
echo "Yes";
6670
}
6771
?>

0 commit comments

Comments
 (0)