Jump to content

not instance of syntax?


Jessica

Recommended Posts

Since this gives an unexpected ! error:

if($section !instanceOf Section){
}

 

I keep doing this:

if($section instanceOf Section){
    //do nada.
}else{
   $this->getSection();
}

 

Is there another way to check if something is not an instanceOf? Am I missing something basic here?

Link to comment
https://forums.phpfreaks.com/topic/87165-not-instance-of-syntax/
Share on other sites

I've never had the need to use "instanceof" yet, however, I would imagine it would work this way instead:

 

if (!$section instanceOf Section) {

}

 

Or:

 

$bolInstance = ($section instanceOf Section);

 

if (!$bolInstance) {

}

 

FYI: is_a() is deprecated as of PHP 5.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.