php 如果刀片文件中的其他条件(laravel 5.3)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40122633/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
if else condition in blade file (laravel 5.3)
提问by user3386779
I want to check if
/else
condition in my blade file. I want to check the condition $user->status =='waiting'
as the code given below. Output returns correctly as I expected. But along with my output I caught curly braces {} printed. I want to remove curly braces in result. Is there anything wrong in my if
condition ?
我想在我的刀片文件中检查if
/else
状况。我想$user->status =='waiting'
按照下面给出的代码检查条件。输出按我的预期正确返回。但是随着我的输出,我发现打印了花括号 {}。我想在结果中删除花括号。我的if
情况有什么问题吗?
@if($user->status =='waiting')
{
<td><a href="#" class="viewPopLink btn btn-default1" role="button" data-id="{{ $user->travel_id }}" data-toggle="modal" data-target="#myModal">Approve/Reject<a></td>
}
@else{
<td>{{ $user->status }}</td>
}
@endif
回答by Rakesh Sojitra
No curly braces required you can directly write
不需要大括号,你可以直接写
@if($user->status =='waiting')
<td><a href="#" class="viewPopLink btn btn-default1" role="button" data-id="{{ $user->travel_id }}" data-toggle="modal" data-target="#myModal">Approve/Reject<a></td>
@else
<td>{{ $user->status }}</td>
@endif
回答by Cengkuru Michael
I think you are putting one too many curly brackets. Try this
我认为您放置了太多的大括号。尝试这个
@if($user->status=='waiting')
<td><a href="#" class="viewPopLink btn btn-default1" role="button" data-id="{!! $user->travel_id !!}" data-toggle="modal" data-target="#myModal">Approve/Reject</a> </td>
@else
<td>{!! $user->status !!}</td>
@endif