【发布时间】:2014-09-10 08:02:43
【问题描述】:
我可以通过两种或多种方式实现该功能 一个为什么要使用更多的回报和回报,每次我不需要继续使用该功能,而另一种方法是使用 更多 ifs,else ifs, elses,
function getCountOfWhatEverMethodType1
{
$return = false;
// ----
if($user->isLogged)
{
if(getDBOBlaBla->equal(1))
{
$return = 2;
}
else if(getDBOBlaBla->equal(2))
{
$return = 3;
}
else
{
$return = 1;
}
}
// ----
return $return;
}
function getCountOfWhatEverMethodType2
{
if(!$user->isLogged)
{
return false;
}
$return = 1;
// ----
if(getDBOBlaBla->equal(1))
{
$return = 2;
}
else if(getDBOBlaBla->equal(2))
{
$return = 3;
}
// ----
return $return;
}
我应该使用一个,为什么?
【问题讨论】:
标签: php if-statement coding-style return