I use the header to allow the user to download a file when he clicks on a button. The below code is in a function.
header('Content-Disposition: attachment;
filename='.date("Ymd",$date).".removethis");
echo $data;
exit();
return true;
but i dont catch the return value when calling the function. Is it possible to have a exit() and yet have a return value from the function?
The function exit()
will terminate the program immediately. So no code execution is expected after exit()
;
exit(); // program terminates
// not executed
return true;
No.
You could return true and then call the exit() in the code that called the function, perhaps?
$val = theFunction($data);
if ($val) {
exit;
} else {
// error or something
}