为什么在这里打破使用?
class Controller
{
public function Controller(&$viewParam)
{
$isSubmit = false;
foreach ($_POST as $key=>$value){
if(isset($_POST[$key])) {
$isSubmit = true;
break;
}
}
if($isSubmit){
$this->onSubmitAction($viewParam);
}
else{
$this->formLoding($viewParam);
}
}
public function formLoding(&$viewParam){}
public function onSubmitAction(&$viewParam){}
}
答案 0 :(得分:1)
关于休息时间,您有很长的路要查看是否有帖子,您可以这样做:
public function Controller(&$viewParam)
{
$isSubmit = ($_SERVER['REQUEST_METHOD'] === 'POST');
if($isSubmit){
$this->onSubmitAction($viewParam);
}
else{
$this->formLoding($viewParam);
}
}
或完全跳过$isSubmit
变量...