Take the 2-minute tour ×

I have been running into a weird issue for some time with php now and wonder if anybody can help. It's probably a totally minor stupid thing I don't see.

"if" statements don't seem to work for me when I use && and || for logical expressions. Latest example:

$isNotSet = !isset($moved); // var_dump prints false
$moveSuccess = $moved instanceof SuccessNotification; // var_dump prints true
if(($isNotSet == true) || ($moveSuccess == true)){

the script always breaks at exactly that line and doesn't go any further. It won't execute anything after this. I have tried lots of things, e.g.

if(!isset($moved) || $moved instanceof SuccessNotification){


if(!isset($moved) === true || $moved instanceof SuccessNotification){


$isNotSet = !isset($moved);
$moveSuccess = $moved instanceof SuccessNotification;
if($isNotSet === true || $moveSuccess === true){

All don't work. I'm aware they all mean the same, I was just trying to eliminate the thought of being on the wrong track. Some of those examples are marked as syntax error in Netbeans, but not all of them, which got me thinking.

I'd like to know what's going on here because this limits coding a lot. But as I said, I probably overlook a totally simple thing.

edit: the script breaks without any errors or warnings shown, it just stops working at that line

edit2: I took the snippet and executed it on its own.

$moved = new SuccessNotification($code, $title, $message);
echo 1;
$isNotSet = !isset($moved);
echo 2;
$moveSuccess = $moved instanceof SuccessNotification;
echo 3;
if(($isNotSet === true) || ($moveSuccess === true) || 1){
    echo 4;    
    echo 5;    
echo 6;

This prints "123", nothing else. And yes, I have included the SuccessNotification class (otherwise there would have been an error anyways) which is being used system-wide already and properly working, just removed that line for posting here. I take it that nobody really has a clue and therefore tries to find a simple solution which is ok because I thought it's just a simple thing. But I realize I have tried everything you suggest or would do in this situation.

share|improve this question
Have you tried printing value of $moveSuccess and $isNotSet before the comparison? –  rccoros Feb 6 at 11:16
yes, it says in the code/comments ;) –  user1021052 Feb 6 at 11:20
Add || 1 in your condition & check if it now goes into the if statement. –  Rikesh Feb 6 at 11:20
It cannot be a syntax error, else the whole thing wouldn't run at all. if statements don't simply "break", no matter what the condition. The problem is likely in some other piece of code you're not showing. –  deceze Feb 6 at 11:32
Cannot reproduce: 3v4l.org/iIkT5 –  deceze Feb 6 at 12:35

1 Answer 1

Shouldnt it be:

if(($isNotSet === true) || ($moveSuccess === true)){

Instead of:

share|improve this answer
to be entirely correct with the type, yes. I have tried both, with and without additional brackets. –  user1021052 Feb 6 at 11:54

Your Answer


