简体   繁体   中英

how to use variable inside laravel @include?

在此处输入图片说明

{{$one = 'testFileName'}}

@include('folder.project.$one')

You can do that

First solution

{{$one = 'folder.project.testFileName'}}

@include($one)

second solution

{{$one = 'testFileName'}}

@include("folder.project.$one")

third solution

{{$one = 'testFileName'}}

@include("folder.project." . $one)

And for define variable you can also use

@php
    $one = 'testFileName';
@endphp

or (but it can depends of laravel version)

@php($one = 'testFileName')

First define variable in PHP tag (not {{ }})

@php($one = 'testFileName')

Second Use variable :

@include('folder.project'.$one)

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