What does return true; and return false; exactly responds in user defined functions?
function valid_image($image, $target, $width, $height = 0) {
if($image["type"] !== "image/jpeg") {
alert('File must be of type image/jpeg');
return false;
}
if(file_exists($target.$image['name'])) {
alert('File Already Exists, Please Choose a Different Name for the File');
return false;
}
return true;
}
Considering the above example if the first condition if($image["type"] !== "image/jpeg" returns true. Does the return false; statement right below it stop the script from executing the below code ?
If the first statement evaluated to true, then the
return falseimmediately under it will end the function (I should say alert() will be called first).