Laravel 中的连接

问题描述

我的代码如下。

<a class="page-link{{ $notification_link['active'] ? 'blue' : '' }}"  {{ $notification_link['url'] == null ? '' : (href="'.route('notification',substr($notification_link['url'],-1)).'") }}>some text</a>

我收到如下错误

Syntax error,unexpected '='

解决方法

您只是缺少一个引号:

<a class="page-link{{ $notification_link['active'] ? 'blue' : '' }}"  {{ $notification_link['url'] == null ? '' : ('href="'.route('notification',substr($notification_link['url'],-1))) }}>some text</a>