$ result = validateUploadedFile ($ _ FILES);
if (!empty($result) && !empty($result['valid']) && $result['valid']) {
The validateUploadedFile function returns an array as $ result ['valid'] == TRUE if it passes.
The question is, is the if statement checked too much? Can I just check the following? I have little knowledge of the PHP language and donβt know if these checks are necessary or not.
if ( $result['valid'] ) { // do sth }
thanks
function validateUploadedFile($uploadedFile) { // Define file size limit $result = array('valid' => FALSE, 'error_message' => null, 'error_code' => 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; }
q0987 source share