语法错误,意外的 ''' (T_STRING) PHP

syntax error, unexpected '′' (T_STRING) PHP

我在 运行 PHP 脚本时遇到以下错误:

Symfony \ Component \ Debug \ Exception \ FatalErrorException
syntax error, unexpected '′' (T_STRING)

。 Symfony\Component\Debug\Exception\FatalErrorException …/app/filters.php:72

    Route::any(‘check/purchase-code’, function() {if ($code = Input::get(‘code’)) {ini_set(‘user_agent’, ‘Mozilla/5.0′);$result = “”;if ($result = 1) {Session::put(‘valid-usage’,’1′);return Redirect::route(‘install-db-info’);}}return Redirect::to(‘/install’);});
Route::filter(‘user-auth’, function()

将所有 个字符替换为 '"

您可能是从网上复制代码,但在复制过程中出了点问题

PHP 中的有效字符串分隔符是引号 ' 和双引号 "。反引号或撇号不在列表中。

查看文档:https://secure.php.net/manual/en/language.types.string.php

替换此行(确定 '"

Route::any(‘check/purchase-code’, function() {if ($code = Input::get(‘code’)) {ini_set(‘user_agent’, ‘Mozilla/5.0′);$result = “”;if ($result = 1) {Session::put(‘valid-usage’,’1′);return Redirect::route(‘install-db-info’);}}return Redirect::to(‘/install’);});
Route::filter(‘user-auth’, function()

至此

Route::any('check/purchase-code', function() {if ($code = Input::get('code')) {ini_set('user_agent', 'Mozilla/5.0');$result = "";if ($result = 1) {Session::put('valid-usage','1');return Redirect::route('install-db-info');}}return Redirect::to('/install');});
Route::filter('user-auth', function()