为什么我用了绝等比较(===)改变了变量值

莱登堡 莱登堡 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

/** @method 防止id越界
* @name strip_and_clean
* @Param integer id
* array array
* @return integer id or 0
*/
function strip_and_clean($id,$array) {
if(is_numeric($id)){
if($id < 0 || $id > count($array)){
$id = 0;
}
}
return intval($id);
}
class ___(){
function _view($id=null){
$id = 1;
$id = $this->strip_and_clean($id,array(1=>1,2=>2,3=>3,4=>4,5=>5));
echo 'before===='.$id;
if ($id === 0) {
echo '<br>after===='.$id;
$this->Session->setFlash(__('不合法的XX!', true));
//exit('不合法的XX!');
}else{
//doing something~~~~~~~~~~~~~~~
}
}
}

为什么我在运行这个程序的时候,会输出:
before====1
after====0
呢?????
-----------------绝等比较(===)不是只比较变量的值和类型是否相等吗?
怎么在这里却赋值了呢???????????????
...全文

相关推荐

评论 4
收藏 已收藏
分享
返回顶部
莱登堡
基础编程 21,889 成员 140,329 内容