Jump to content

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.

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.