views:

48

answers:

2

I am running an if statement, that looks like this,

if($this->uri->segment(1) !== 'search' || $this->uri->segment(1) !== 'employment') {
    //dome something
}

My problem is that first condition works, if the uri segment 1 equals search then the method do not run however if I on the page employment, and the first segment of the uri is employment then the condition still runs, why is this?

A: 

You are looking for this i think:

if($this->uri->segment(1) === 'search' || $this->uri->segment(1) === 'employment') {
    //dome something
}

Use === instead of !==

Sarfraz
+2  A: 

you have to do

if($this->uri->segment(1) === 'search' || $this->uri->segment(1) === 'employment') {
    //do something
}

or

if($this->uri->segment(1) !== 'search' && $this->uri->segment(1) !== 'employment') {
    //do something
}

depending on what you want to do... asking for (bla!=blubb || bla!=blah) doen't make any sense because it will be true everytime.

oezi