gpt4 book ai didi

php - 如何在 laravel @include 中使用变量?

转载 作者:行者123 更新时间:2023-12-02 00:25:45 25 4
gpt4 key购买 nike

enter image description here

{{$one = 'testFileName'}}

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

最佳答案

你可以做到这一点

第一个解决方案

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

@include($one)

第二种解决方案

{{$one = 'testFileName'}}

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

第三种解决方案

{{$one = 'testFileName'}}

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

对于定义变量你也可以使用

@php
$one = 'testFileName';
@endphp

或(但它可以取决于 laravel 版本)

@php($one = 'testFileName')

关于php - 如何在 laravel @include 中使用变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53847465/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com