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 Commented Dec 19, 2018 at 8:45
  • 3
    To explain ^^, double quotes will evaluate variables in a string. See php.net/string Commented 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 Commented 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')
Sign up to request clarification or add additional context in comments.

Comments

1

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

@php($one = 'testFileName')

Second Use variable :

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

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.