CodeIgniter PHP 解析错误意外 '{',期待 '('

CodeIgniter PHP Parsing Error unexpected '{', expecting '('

这是怎么回事 PHP 解析错误 意外的“{”,期待“(”

没有回溯,没有任何其他错误消息,控制器中只有一行,仅此而已-_-

我一直在寻找解决方案并阅读许多与此相关的链接。

我下面的代码出错的原因可能是什么..

这个我的控制器代码(工作正常):

if (isset($filter) && !empty($search)) {
            $data['users'] = $this->model_search->searchTutor($field, $search);
        }
        elseif (($filter == 'subjName') && !empty($search)) {
            $data['users'] = $this->model_search->searchBySubj($field, $search);
        }
        else {
            $data['users'] = $this->model_search->getlist($field);
        }

        //later i wanted to add a code that will show No Result Found

当我在我的控制器 (Search.php) 中添加 elseif 语句时,我页面的视图文件开始出现此错误 :

if (isset($filter) && !empty($search)) {
            $data['users'] = $this->model_search->searchTutor($field, $search);
        }
        elseif (($filter == 'subjName') && !empty($search)) {
            $data['users'] = $this->model_search->searchBySubj($field, $search);
        }
        //so I added another elseif
        elseif (isset($filter) && empty($search)) {
            $data['users'] = $this->model_search->getlist($field);
        }
        //and put the No Result last
        else {
            $this->session->set_flashdata('nores','<div class="alert text-center">No result matched your search.</div>');
        }

是因为多重 elseif 条件还是我真的遗漏了什么?请帮忙..

elseif {

您的新 elseif 没有条件。您预计它什么时候会 运行?您需要添加一个条件。