Laravel Blade:尝试导入的php文件存在

bny*_*ynn 1 php if-statement include laravel blade

你会如何使用blade的@import方法做到这一点?我试过了:

@if (@include('/path/to/phpfile'))
    @include('/path/to/phpfile')
@else
    <h2>Oops! It doesn't look like this page exists!</h2>
@endif
Run Code Online (Sandbox Code Playgroud)

也试过file_exists(),没有骰子:(

The*_*pha 7

你可以试试这个:

@if(View::exists('viewname'))
    @include('viewname')
@endif
Run Code Online (Sandbox Code Playgroud)