note 116856 deleted from internals2.opcodes.instanceof by cmb
| From: | cmb@php.net | Date: | Sun, 10 Jan 2021 13:21:42 +0000 |
| Subject: | note 116856 deleted from internals2.opcodes.instanceof by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-216099@lists.php.net to get a copy of this message | ||
Note Submitter: krall dot eugene at gmail dot com
----
When checking instanceof against a class that implements the class in question, it will return true.
<?php
interface ExampleInterface
{
public function interfaceMethod();
}
class ExampleClass implements ExampleInterface
{
public function interfaceMethod()
{
return 'Hello World!';
}
}
$exampleInstance = new ExampleClass();
if($exampleInstance instanceof ExampleInterface)
echo 'Yes, it is';
else
echo 'No, it is not';
?>
The result:
Yes, it is