Home  >  Article  >  Backend Development  >  为什么这段代码没效果

为什么这段代码没效果

WBOY
WBOYOriginal
2016-06-06 20:18:271321browse

DIARYBLOG';
} elseif ($_GET['cate']='blog') {
echo 'DIARYBLOG';
} 
?>

不管为cate设置什么值都输出DIARYBLOG

回复内容:

DIARYBLOG';
} elseif ($_GET['cate']='blog') {
echo 'DIARYBLOG';
} 
?>

不管为cate设置什么值都输出DIARYBLOG

DIARYBLOG';
} elseif ($_GET['cate']=='blog') {
echo 'DIARYBLOG';
} 
?>

== 符号写错了

$_GET['cate']================='diary'

粗心的小明, if条件第二个表达式永远为真 elseif的条件也是。

粗心的小明死在了==上了

你以后写 逻辑表达式的时候,养成把期望值放在前面的习惯,这样,你不小心把==打成=的时候,就会报错。个人认为编码风格可以参考CI框架的,他的文档上面会有说明

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn