douchi0638 2018-01-18 05:02
浏览 132
已采纳

当我尝试在laravel中发送重置密码链接时出现解析错误

I am using Laravel 5.4. I am getting error when i try to request password reset link.

Symfony\Component\Debug\Exception\FatalThrowableErrorPOST /password/email Parse error: syntax error, unexpected '?', expecting variable (T_VARIABLE)

File that error is pointing to is this ( at line 'return $next($request)'

app/Http/Middleware/RedirectIfAuthenticated.php:24App\Http\Middleware\RedirectIfAuthenticated::handle

 namespace App\Http\Middleware;
 use Closure; 
 use Illuminate\Support\Facades\Auth;

 class RedirectIfAuthenticated {
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if (Auth::guard($guard)->check()) {
         return redirect('/');
     }

     return $next($request);
 } 
}

I debugged further into code and found out that this function is prolly causing issue.
FILE NAME:Symfony\Component\CssSelector\XPath\Extension\AttributeMatchingExtension

public function translateExists(XPathExpr $xpath, string $attribute, ?string $value): XPathExpr
{
    return $xpath->addCondition($attribute);
}
  • 写回答

1条回答 默认 最新

  • dsyk33753 2018-01-23 10:42
    关注

    I had the same issue with php 7.0.23 and Laravel 5.5 using the php mail() function:

    Parse error: syntax error, unexpected '?', expecting variable (T_VARIABLE) at [...]/vendor/symfony/css-selector/XPath/Extension/AttributeMatchingExtension.php:46

    The problem was solved by upgrading to version php 7.1+. (php 7.1.9 in my case)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘