instanceof / __CLASS__ question
| From: | Jason Barnett | Date: | Tue, 31 Aug 2004 19:20:25 +0000 |
| Subject: | instanceof / __CLASS__ question | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-195326@lists.php.net to get a copy of this message | ||
It's only a minor nuisance, but in order to use __CLASS__ with instanceof I have to assign __CLASS__ to a variable first. Should I bother submitting a bug report for this? Or am I perhaps missing something...
<?php
class Test {
function checkObj2()
{
//workaround
$class = __CLASS__;
if ($this instanceof $class) {
return TRUE;
} else {
return FALSE;
}
}
function checkObj()
{
// this causes a parsing error
// return ($this instanceof __CLASS__);
}
}
$t = new Test();
echo $t->checkObj2() ? 'TRUE' : 'FALSE';
echo $t->checkObj(); // can't even test it
?>