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.

3
  • Does the error message specify which file the syntax error is in? Commented Mar 21, 2017 at 8:09
  • @RossWilson yes in this exact method in controller. Commented Mar 21, 2017 at 8:10
  • Do you mean you get this error ONLY in the production server and not in your local environment? Commented Mar 21, 2017 at 8:14

2 Answers 2

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');
Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.