1
当我收到我的控制器一个数字,它传递给这样的观点:Laravel for循环错误
public function show(Request $request)
{
$products = $request->products;
return view('admin.administration')->with('products',$products);
}
,并显示在我的观点是这样的:
<div class="form-group">
@for($i=0; $i <{{ $products }}; $i++)
<div class="form-group">
<label for="rol" class="col-lg-2 control-label">Product:</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="title>" placeholder="Titel" name="title>">
<input type="text" class="form-control" id="description>" placeholder="Beschrijving" name="description>">
<input type="text" class="form-control" id="price>" placeholder="prijs" name="price">
<input type="text" class="form-control" id="number>" placeholder="Aantal" name="number">
<input type="text" class="form-control" id="total>" placeholder="Totaal" name="total">
</div>
</div>
@endfor
</div>
它抛出以下错误:
Parse error: syntax error, unexpected '?' (View: /home/vagrant/Code/l/resources/views/admin/administration.blade.php)
使用dd选中,但值不为空。当我用例5替换{{$ products}}时,它可以工作。我该怎么办?