【发布时间】:2018-03-13 18:33:38
【问题描述】:
这真的是一个标准吗?,我找不到任何信息
“不为将立即使用的变量赋值”
例如,这样更好吗:
$isHuman = true; // or false
$entity = new Something();
$this->whatever($something, $isHuman);
比这个:
$entity = new Something();
$this->whatever($something, true); // is prefeareable to use "true/false" directly?
【问题讨论】:
-
你不认为这取决于
$isHuman是否是动态的吗? -
可能基于意见,但如果您只使用一次
$isHuman,请不要使用它。 -
考虑@LawrenceCherone 评论
$isHuman = isset($_POST['something']); -
是的,当然是动态的,在某些情况下也可能是假的
-
取决于您以后是否要在其他地方使用
$isHuman
标签: php coding-style standards