note 111047 deleted from function.is-subclass-of by aharvey

From: Date: Thu, 10 Jan 2013 02:04:56 +0000
Subject: note 111047 deleted from function.is-subclass-of by aharvey
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-192867@lists.php.net to get a copy of this message
Note Submitter: tinkertim at gmail dot com ---- 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.

« previous php.notes (#192867) next »