smehsoud smehsoud - 5 months ago 10
PHP Question

OR " || " opreator not working in if statement in php

I am using codeigniter and wants to shwo the js code only if following condition true

if(($this->uri->segment(1)!='reports') || ($this->uri->segment(2)!='manageflyers' && $this->uri->segment(3)!='save')){?>
//some js code
<?php }?>

But i does not work please help where i am making the mistake.


A couple of != with an OR || will always equal true because that string variable will only equal one thing and not be the other

so your code will work like this

if(($this->uri->segment(1)=='reports') || ($this->uri->segment(2)=='manageflyers' && $this->uri->segment(3)=='save')){ 
    //do nothing
    //some js code