4

I'm facing some error that saying Parse error: syntax error, unexpected '<'

This is my views in Laravel

               @for($i = 0;$i < 6;$i++)
                    <tr>
                    <td>{{date("Y", strtotime($data[$i]->date))}}</td>
                    <td>{{date("M", strtotime($data[$i]->date))}}</td>
                    <td>{{$data[$i]->total}}</td>
                    <td>{{$st[$i]}}</td>
                    <td>{{$bt[$i]}}</td>

                    @if({{$ftm[$i]}}==null)
                        <td></td>
                    @elseif({{$ftm[$i]}}!=null)
                        <td>{{$ftm[$i]}}</td>
                    @endif

                    <td>{{$pe[$i]}}</td>
                    </tr>
                @endfor

Is there any solution?

2
  • 1
    which line does it say? Commented Apr 28, 2017 at 8:29
  • @BenLonsdale Good question +1. Anyway, I found where the error is without that: look at the @if({{$ftm[$i]}}==null) line. Commented Apr 28, 2017 at 8:42

1 Answer 1

11

You dont need to add {{ }} when your variable is in a @if statement.

Replace:

@if({{$ftm[$i]}}==null)
     <td></td>
@elseif({{$ftm[$i]}}!=null)
     <td>{{$ftm[$i]}}</td>
@endif

With:

@if($ftm[$i]==null)
    <td></td>
@elseif($ftm[$i]!=null)
    <td>{{$ftm[$i]}}</td>
@endif
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.