T_BOOLEAN_AND error?

落爺英雄遲暮 提交于 2019-12-02 20:24:37

问题


whats wrong with this? anybody help me please..

if(stripos($nerde, $hf) !== false) && (stripos($nerde, $rs) !== false){
    @mysql_query("update table set dltur = '3' where id = '".$ppl[id]."'");

}
else {
//dont do anything
}

i get T_BOOLEAN_AND error.


回答1:


The entire condition needs parentheses:

if((stripos($nerde, $hf) !== false) && (stripos($nerde, $rs) !== false)){



回答2:


The whole expression of an if condition needs to be put in parentheses. But you’re already closing that part of the if statement after the first false:

if(stripos($nerde, $hf) !== false) && (stripos($nerde, $rs) !== false){
  ^       ^___________^          ^
  |______________________________|

Write it this way:

if (stripos($nerde, $hf) !== false && stripos($nerde, $rs) !== false)

Or you put parentheses around the whole expression (Ignacio Vazquez-Abrams suggested):

if ((stripos($nerde, $hf) !== false) && (stripos($nerde, $rs) !== false))


来源:https://stackoverflow.com/questions/2641595/t-boolean-and-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!