Php Laravel语法错误,意外的'and'(T_LOGICAL__and),应为''

Php Laravel语法错误,意外的'and'(T_LOGICAL__and),应为'',php,laravel-4,Php,Laravel 4,我正在为我当前的项目使用Laravel4。我的web应用程序中有一个搜索功能。这是我的搜索功能代码,位于my controller.php文件中 public function postBloodSearch(){ $blood_group = Input::get('blood_group'); $location = Input::get('location'); if(empty($blood_group and $location)){

我正在为我当前的项目使用Laravel4。我的web应用程序中有一个搜索功能。这是我的搜索功能代码,位于my controller.php文件中

public function postBloodSearch(){

        $blood_group = Input::get('blood_group');
        $location = Input::get('location');

        if(empty($blood_group and $location)){

            return Redirect::route('donors')
                    ->with('global','You have to enter both Blood Group and Location');
        }

        $result = Donor::where('blood_group','LIKE','%'.$blood_group.'%')->where('location','LIKE','%'.$location.'%')->get();
        return View::make('bloodDonation.blood_array')->with('result',$result);


}
您可以看到,在我的代码中,我使用了php内置的空函数,而实际上我面对的是空函数 下面的错误

syntax error, unexpected 'and' (T_LOGICAL_AND), expecting ')'
syntax error, unexpected '&&' (T_LOGICAL_AND), expecting ')'
我已经尝试了以下代码来解决这个问题,只需将and替换为&

现在它抛出以下错误

syntax error, unexpected 'and' (T_LOGICAL_AND), expecting ')'
syntax error, unexpected '&&' (T_LOGICAL_AND), expecting ')'
更新:同样的代码在我的本地服务器XAMPP服务器上运行得非常好。但是在我的实时服务器上,我使用的是Cpanel,它会抛出这些错误。

而不是

if(empty($blood_group and $location)){
试一试

在上面的调用中,您将向传递一个布尔值。错误原因如下所述:

注意:在PHP5.5之前,empty只支持变量;别的 将导致分析错误。换言之,以下情况不会发生 工作:emptytrim$name。相反,请使用trim$name==false

如果$blood_group和$location