note 111047 added to function.is-subclass-of
| From: | tinkertim at gmail dot com | Date: | Wed, 09 Jan 2013 12:00:32 +0000 |
| Subject: | note 111047 added to function.is-subclass-of | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-192859@lists.php.net to get a copy of this message | ||
It's also extremely simple to use the instanceof operator.
For example:
<?php
class A
{
public function foo()
{
return 1;
}
}
class B extends A
{
public function bar()
{
return 0;
}
}
class C
{
public function foobar()
{
return -1;
}
}
$test = new B();
$test1 = new C();
if ($test instanceof A) echo 'B is an instance of A';
if (! $test1 instanceof A) echo 'C is not an instance of A';
?>
Both statements print as expected.
----
Server IP: 69.147.83.199
Probable Submitter: 112.201.140.138
----
Manual Page -- http://php.net/manual/en/function.is-subclass-of.php
Edit -- https://master.php.net/note/edit/111047
Del: integrated -- https://master.php.net/note/delete/111047/integrated
Del: useless -- https://master.php.net/note/delete/111047/useless
Del: bad code -- https://master.php.net/note/delete/111047/bad+code
Del: spam -- https://master.php.net/note/delete/111047/spam
Del: non-english -- https://master.php.net/note/delete/111047/non-english
Del: in docs -- https://master.php.net/note/delete/111047/in+docs
Del: other reasons-- https://master.php.net/note/delete/111047
Reject -- https://master.php.net/note/reject/111047
Search -- https://master.php.net/manage/user-notes.php