PHP中可以这样写if语句吗?还是我想多了
public function getAreaList($pid = -1) {<br />
$map = array();<br />
$pid != -1 && $map['pid'] = $pid;<br />
return $this->where($map)->order('`area_id` ASC')->findAll();<br />
}
$pid != -1 && $map['pid'] = $pid;
return $this->where($map)->order('`area_id` ASC')->findAll();
这两句没条件关系吧?上面的一句为什么要用&&连接呢?与直接写
$pid != -1;
$map['pid'] = $pid;
的区别是什么呢?
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