Is this conditional check overkill?
<pre><code>$result = validateUploadedFile($_FILES);

if (!empty($result) &amp;&amp; !empty($result['valid']) &amp;&amp; $result['valid'])
{
    // do sth
    // I don't know why sometime this three checks will cause me problems
    // In other words, even if $result['valid'] is TRUE, this scope will not be hit
}
</code></pre>

<p>The function validateUploadedFile returns an array as $result['valid'] == TRUE if it goes through.</p>

<p>Here is the question, does the if statement checks too much?
Can I simply check the following instead? I have few PHP language knowledge and don't know whether those checks are necessary or not.</p>

<pre><code>if ( $result['valid'] )
{
    // do sth
}
</code></pre>

<p>Thank you</p>

<pre><code>function validateUploadedFile($uploadedFile)
{
    // Define file size limit
    $result = array('valid' =&gt; FALSE, 'error_message' =&gt; null, 'error_code' =&gt; null);

    if (sth_wrong)
    {
      $result['error_message'] = 'sth_wrong';
      return $result;    
    }

    if (sth_wrong2)
    {
      $result['error_message'] = 'sth_wrong2';
      return $result;    
    }    

    $result['valid'] = TRUE;
    return $result;
}
</code></pre>
