PHP: Where to place return 'false' value?

Posted by Mike on Stack Overflow See other posts from Stack Overflow or by Mike
Published on 2010-05-13T03:12:23Z Indexed on 2010/05/13 3:24 UTC
Read the original article Hit count: 238

Filed under:
|

Is one of the following functions better than the other, in terms of where to place the 'return false' statement?

Function #1:

function equalToTwo($a, $b)
{
    $c = $a + $b;
    if($c == 2)
    {
        return true;
    }
    return false;
}

Function #2:

function equalToTwo($a, $b)
{
    $c = $a + $b;
    if($c == 2)
    {
        return true;
    }
    else
    {
        return false;
    }
}

Thanks!

© Stack Overflow or respective owner

Related posts about php

Related posts about best-practices