Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

In Laravel 5.0.27 I am including a view with with a variable and the following code:

@include('layouts.article', [
        'mainTitle' => "404, page not found",
        'mainContent' => "sorry, but the requested page does not exist :("
    ])

and I get the following error...

FatalErrorException syntax ... error, unexpected ','

I've narrowed down that the error is solely from the "(" in the "mainContent" variable string, and when I remove the "(" the error disappears and everything runs fine. I can't find anything in documentation on this or any similar errors listed online.

Does anyone know if this is expected behavior or if this is a bug that should be reported?

Thanks so much for your time!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
379 views
Welcome To Ask or Share your Answers For Others

1 Answer

It's not a bug but a limitation of blade syntax due to regex. Solution came from github:

The problem is using multi-line. You can only use a single line to [pass variables] in Blade, since syntax is limited [by regular expressions]

Try the code below and you should be good to go:

@include('layouts.article', ['mainTitle' => "404, page not found", 'mainContent' => "sorry, but the requested page does not exist :("])

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...