简体   繁体   中英

Declaring variables in blade template

I have defined variable in blade template but it is not working. I am not getting any value of i. The column is blank.

<thead style='background-color:silver'><tr><td>S.N.</td><td>Name</td><td>Telephone No.</td><td>Mobile No.</td><td width="24%">Options</td></tr></thead>
<?php $i=1;?>
@foreach ($lists as $li)
<tr><td><?php $i++;?></td><td>{{$li->Name}}</td><td>{{$li->Telephone}}</td><td>{{$li->mobile}}</td>
<td><a href="{{url("/telephone/show/{$li->id}")}}"><button>View details</button></a>
<a href="{{url("/telephone/edit/{$li->id}")}}"><button>Edit</button></a>
<a href="{{url("/telephone/delete/{$li->id}")}}"><button>Delete</button></a></td></tr>
@endforeach
{!! $lists->render() !!}

This code will definitely work:

<?php $i = 1; ?>
....
<?php $i++; ?>
....
{{-- This will output 2 --}}
{{ $i }}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM