2

enter image description here

{{$one = 'testFileName'}}

@include('folder.project.$one')
3
  • 4
    @include("folder.project.$one") note the double quotes. it's basically PHP string rules
    – apokryfos
    Dec 19, 2018 at 8:45
  • 3
    To explain ^^, double quotes will evaluate variables in a string. See php.net/string
    – Jonnix
    Dec 19, 2018 at 8:45
  • 3
    or you could use like @include("folder.project.".$one) and if you want to pass $one to folder.project then you can pass it as second parameter
    – Sohel0415
    Dec 19, 2018 at 8:48

2 Answers 2

5

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')
1

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

@php($one = 'testFileName')

Second Use variable :

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.