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

From: Date: Mon, 13 Oct 2025 11:37:13 +0000
Subject: [doc-en] master: isinstance.xml Make the example workable and semantic (#4903)
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-22801@lists.php.net to get a copy of this message
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"; } ?>

« previous php.doc.cvs (#22801) next »