Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jamiegen2323's avatar

Php

hi,

What is the deference between these 2?:

if ($item->id != $ignoreSet)

and

if (!$item->id == $ignoreSet)

merci

0 likes
2 replies
tomopongrac's avatar

With this

!$item->id

you are getting boolean

you can see that with this

var_dump(!$item->id);
BryceSharp's avatar

They are very different.

if ($item->id != $ignoreSet)

Here you read the value of $item->id, read the value of $ignoreSet, and compare if they equal then negate the result.

if (!$item->id == $ignoreSet)

Here you read the value of $item->id and negate it, read the value of $ignoreSet and then compare the negation of $item->id to the value of $ignoreSet.

Furthermore these are the same:

if ($item->id != $ignoreSet)

if (!($item->id == $ignoreSet))
1 like

Please or to participate in this conversation.