$x instanceof __CLASS__

php.internals

Jochem Maas

20 years ago
hi there, a quick question regarding whether the following is by design, because it causes a parse error (the code I tried out did occur within a class definition ! :-): if (!$field instanceof __CLASS__) { // do something } where as this obviously does work: $class = __CLASS__; if (!$field instanceof $class) { // do something } as does this: if (!$field instanceof self) { // do something } rgds, jochem

Marcus Börger

20 years ago
Hello Jochem, right now it's by design, instanceof takes a T_STRING or a variable. __CLASS__ returns a const string which is different form a T_STRING. marcus Tuesday, December 27, 2005, 3:30:48 PM, you wrote:
> hi there,
> a quick question regarding whether the following is by design, > because it causes a parse error (the code I tried out did occur within > a class definition ! :-):
> if (!$field instanceof __CLASS__) { > // do something > }
> where as this obviously does work:
> $class = __CLASS__; > if (!$field instanceof $class) { > // do something > }
> as does this:
> if (!$field instanceof self) { > // do something > }
> rgds, > jochem
Best regards, Marcus