2016-05-30 153 views
0

我在刀片模板中定义了变量,但它不起作用。我没有得到任何价值。该列是空白的。声明刀片模板中的变量

<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() !!} 

回答

1

此代码肯定会工作:

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

什么是错我的吗?看起来相似。该列中没有显示任何内容。 – micky

+0

@micky,你说在Blade模板中声明变量不起作用。我把你的代码,测试它,并说它的工作原理。我发布了测试代码。 –

+0

哦。谢谢。我刚刚宣布,忘了打印。 – micky