Jump to content

Negating isNull()


doubledee

Recommended Posts

!=null

!==null

!is_null()

 

all do the same thing. however issetwill sometimes return true even if null. however something i read somewhere said doing !is_null(var) is 10 times slower than using !=null or !==null.

 

Based on the benchmark I just ran, == null was like .4 microseconds faster than is_null(). I'm assuming the reason is because is_null() is an extra function call. Either way, it's a negligible difference.

Link to comment
Share on other sites

Debbie,

  I believe this is the 2nd of these threads that I've seen where you are asking what the ! operator does.  I'd encourage you to put some time into understanding logical operators so that you don't have to repeat these types of questions. 

 

I would also encourage you not to use functions when a simple comparison will do.  Functions always have some overhead, and with php language built-ins like isset() will always be preferrable to other ways of doing things from a performance standpoint. 

 

In this case:

 

if (!(is_null($activationCode)) {
//...
}

 

Can be written either as:

 

if ($activation != null) {

}

 

or depending, on the nature of how $activation is getting its value:

 

if ($activation !== null) {

}

 

In short, try not to use the not operator, not to mention the is_null() function when you don't have to, and this is a case where you clearly don't.

Link to comment
Share on other sites

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.