PHP if not equal(!=) and or (||) issue. Why doesnt this work?

前端 未结 6 1453
暗喜
暗喜 2021-01-06 10:22

I know this is simple PHP logic but it just won\'t work...

 $str = \"dan\";
 if(($str != \"joe\") 
   || ($str != \"danielle\")
   || ($str != \"heather\")
          


        
6条回答
  •  暖寄归人
    2021-01-06 10:39

    Another approach is

    $name = 'dan';
    $names = array('joe', 'danielle', 'heather', 'laurie', 'dan');
    
    if(in_array($name,$names)){  
        //the magic
    }
    

提交回复
热议问题