Php URI troube with if statement,

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 the first condition works, if the uri segment 1 is equal to the search, then the method does not work, however, if I am on the work page and the first uri segment is busy, then the condition still works, why is this

+2


a source to share


2 answers


Are you looking for this I think:

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

      



Use ===

instead!==

0


a source


you need 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 (bla!=blubb || bla!=blah)

doesn't make any sense because it will be true every time.

+2


a source







All Articles