I need to check if the displayed number is greater than or equal to 1, or not equal to 0, then we display it
I am trying to do this but I get the error
<span class="comments">
@if({{ $allArticleCommentsCount }} >= 1) {{ $allArticleCommentsCount }} @endif Comments
</span>
syntax error, unexpected '<'
删除 if 语句中的刀片语法,您就可以开始了。
@if($allArticleCommentsCount >= 1) {{ $allArticleCommentsCount }} @endif Comments
You have multiple solution:
<span class="comments">
@if( $allArticleCommentsCount >= 1)
{{ $allArticleCommentsCount }}
@endif Comments
</span>
<span class="comments">
{{ $allArticleCommentsCount >= 1 ? $allArticleCommentsCount : '' }}
</span>
@php
if(! $allArticleCommentsCount >= 1) {
$allArticleCommentsCount = '';
}
@endphp
<span class="comments">
{{ $allArticleCommentsCount }}
</span>
I would prefer the first solution.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.