我使用标题来允许用户在单击按钮时下载文件。下面的代码在一个函数中。
header('Content-Disposition: attachment;
filename='.date("Ymd",$date).".removethis");
echo $data;
exit();
return true;
但是我在调用函数时没有捕捉到返回值。是否有可能有一个 exit() 却有一个函数的返回值?
我使用标题来允许用户在单击按钮时下载文件。下面的代码在一个函数中。
header('Content-Disposition: attachment;
filename='.date("Ymd",$date).".removethis");
echo $data;
exit();
return true;
但是我在调用函数时没有捕捉到返回值。是否有可能有一个 exit() 却有一个函数的返回值?
不。
您可以返回 true,然后在调用该函数的代码中调用 exit(),也许?
$val = theFunction($data);
if ($val) {
exit;
} else {
// error or something
}
该函数exit()
将立即终止程序。exit()
所以在;之后不会执行任何代码。
exit(); // program terminates
// not executed
return true;