[DOC-CVS] [doc-en] master: isinstance.xml Make the example workable and semantic (#4903)

[email protected] (Mikhail Alferov via GitHub)
Newsgroups php.doc.cvs
Message-ID <[email protected]>
Author: Mikhail Alferov (mmalferov)
Committer: GitHub (web-flow)
Pusher: kamil-tekiela
Date: 2025-10-13T12:37:11+01:00

Commit: https://github.com/php/doc-en/commit/eb557099ed1ddbc49c941f868d896991190b14f8
Raw diff: https://github.com/php/doc-en/commit/eb557099ed1ddbc49c941f868d896991190b14f8.diff

isinstance.xml Make the example workable and semantic (#4903)

Changed paths:
  M  reference/reflection/reflectionclass/isinstance.xml


Diff:

diff --git a/reference/reflection/reflectionclass/isinstance.xml b/reference/reflection/reflectionclass/isinstance.xml
index 819c56de9bda..fcf6208f7b7a 100644
--- a/reference/reflection/reflectionclass/isinstance.xml
+++ b/reference/reflection/reflectionclass/isinstance.xml
@@ -48,20 +48,24 @@
     <programlisting role="php">
 <![CDATA[
 <?php
-// Example usage
-$class = new ReflectionClass('Foo');
 
-if ($class->isInstance($arg)) {
-    echo "Yes";
+class Foo {}
+
+$object = new Foo();
+
+$reflection = new ReflectionClass('Foo');
+
+if ($reflection->isInstance($object)) {
+    echo "Yes\n";
 }
 
 // Equivalent to
-if ($arg instanceof Foo) {
-    echo "Yes";
+if ($object instanceof Foo) {
+    echo "Yes\n";
 }
 
 // Equivalent to
-if (is_a($arg, 'Foo')) {
+if (is_a($object, 'Foo')) {
     echo "Yes";
 }
 ?>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.