【发布时间】:2016-10-28 23:49:14
【问题描述】:
<select id="year" name="year" class="form-control ">
{{ $last= date('Y')-120 }}
{{ $now = date('Y') }}
@for ($i ={{ $now }}; $i <= {{ $last }}; $i--)
<option value="{{ $i }}">{{ $i }}</option>
@endfor
</select>
我收到了错误消息Parse error: syntax error, unexpected '<'
看起来变量无法读取。
如何在for循环中设置值?
【问题讨论】:
-
试试这个
@for ($i =$now; $i <= $last; $i--) -
在刀片模板中,
@指令中的任何内容(例如您的@for())都将被视为 php,因此无需使用{{ }}打印它的值。