FilipeCosta FilipeCosta - 1 month ago 27
PHP Question

php artisan serve parse error

i know this question already exist, but i could not solve via the other responses, so the first time i runed php artisan serve it worked, i changed the routes so the logic go to the controllers and they can call the views, so i have this at the moment.

Routes

Route::get('/',PagesController@home);
Route::get('about',PagesController@about);


PagesController

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;

class PagesController extends Controller
{
public function home(){
$People = array("Joao","Miguel","Carlos");
return view('welcome',compact('People'));
}

public function about(){
return view ("pages.about");
}
}


when i changed the routes i turned off the connection via local server on my cmd, after that i tryed again the command php artisan serve and now i get a parse error like this:


[Symfony\Component\Debug\Exception\FatalThrowableError]
Parse error: syntax error, unexpected '@', expecting ',' or ')'


routes before

Route::get('/', function () {
$People = array("Joao","Miguel","Carlos");
return view('welcome',compact('People'));
});

Route::get('/about',function(){
return view ("pages.about");
});


Have no idea why this happens :S if someone can give me a tipe i appreciate :)

Answer

This:

Route::get('about',PagesController@about);
                                  ^--

there's no quotes, so that's <undefinedconstant>@<undefinedconstant>

@ is the error suppression operator in PHP, and cannot appear "inside" a variable/constant name.

Comments