Blogger Information
Blog 27
fans 1
comment 0
visits 22526
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
blade模版引擎的语法-2019年11月5日
思杰的博客
Original
829 people have browsed it

练习一下blade模板的语法。如:变量渲染、foreach、if...else...2、include、section


blade模版引擎的用法主要有以下几个

image.png

if语句:

@if (count($records) === 1)

    I have one record!@elseif (count($records) > 1)

    I have multiple records!

@else

    I don't have any records!

@endif

switch语句

@switch($i)

    @case(1)

        First case... 

        @break

    @case(2)

        Second case...

        @break

    @default

        Default case...

@endswitch

for循环和foreach循环

@for ($i = 0; $i < 10; $i++)

    The current value is {{ $i }}

@endfor

@foreach ($users as $user)

    <p>This is user {{ $user->id }}</p>

@endforeach

引入子视图

@include('shared.errors')
















Correction status:qualified

Teacher's comments:合格
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments