I have basic question for you guys
i have php function which verifies and creates the file handler name for the given type,
however i just want to know if the following code goes to a else, will the next lines of the coding of creating the guid will be executed or will it be ignored ?
private function fileFormat($type=false){
if($type=='CreditCard')
$prefix='CC-';
elseif($type=='DirectDebit')
$prefix='DD-';
else
return false;
$date = $prefix.'-'.date('d-m-Y', time());
$guid = '' . md5($date) . '.csv';
return $guid;
}
Not to beat a dead horse, now that there are a number of answers stating the same thing… but here is my clarification.
After a
returnis executed, no remaining code will be executed. The way you have setup your code is fine, assuming you want afalsereturned if neither of the$types are encountered. This is a common control flow and is preferred over setting a flag and checking the flaw before return.Is preferred (for me) over: