[英]How do I get the return variable from a function inside another function
Using an Excel library , how do I make function check_stuff
return false
when needed? 使用Excel库 ,如何在需要时使函数
check_stuff
返回false
? As of right now, $this->check_stuff($path)
always returns true
. 截至目前,
$this->check_stuff($path)
始终返回true
。 Keep in mind that I cannot modify class Excel
. 请记住,我无法修改
Excel
类。
private function check_stuff($path) {
Excel::filter('chunk')->load($path)->chunk(250, function($results) {
// check something
return false;
});
return true;
}
Try to import it in the anonymous function: 尝试将其导入匿名函数中:
private function check_stuff($path) {
$result = true;
Excel::filter('chunk')->load($path)->chunk(250, function($results) use (&$result) {
// check something
$result = false;
});
return $result;
}
Have you tried this? 你有尝试过吗?
private function check_stuff($path) {
return Excel::filter('chunk')->load($path)->chunk(250, function($results) {
// check something
return false;
});
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.