1

I have this link:

   <a href="{{url('/list')}}">List of all members</a>

and this route:

Route::get('/list', 'NyfnController@list');

controller method:

public function list()
    {
        $users=User::orderBy('district_involved')->get();
        return view('list')->with('users',$users);
    }

But, i got the syntax error:

syntax error, unexpected 'list' (T_LIST), expecting identifier (T_STRING)

This works fine on localhost, but not on server.

Steve
  • 1,622
  • 5
  • 21
  • 39

2 Answers2

2

Probably your localhost is running 5.6.4> and your webserver is running 7.*.

In php 7 the list method is not available. If you use PHPStorm you got a notice that list is a new method in PHP 7 (or newer). Have a look at: http://php.net/manual/en/function.list.php#refsect1-function.list-changelog

I would recommend you to change you method:

public function listUsers()
{
    $users=User::orderBy('district_involved')->get();
    return view('list')->with('users',$users);
}

Route::get('/list', 'NyfnController@listUsers');
Robin Dirksen
  • 3,322
  • 25
  • 40
0

It happens that list is a reserved word (http://php.net/manual/en/function.list.php), actually a language construct, and therefore you cannot define a function with that name. Use whatever other (not reserved) name you want.

Amarnasan
  • 14,939
  • 5
  • 33
  • 37