# 条件

首先让我们看下逻辑控制结构

***@if***

Blades的 @if(条件)会被编译成\<?php if ($condition) : ?>。@else,@elseif,以及@endif 也会被编译成PHP语法结构样式,如示例4-2所示

{% code title="Example 4-2. @if, @else, @elseif, and @endif" %}

```php
@if (count($talks) === 1)
There is one talk at this time period.
@elseif (count($talks) === 0)
There are no talks at this time period.
@else
There are {{ count($talks) }} talks at this time period.
@endif
```

{% endcode %}

就像原生的PHP条件判断一样,你可以混合跟匹配你想要的.它们没有任何特殊的逻辑,实际上，解析器会查找@if（$ condition）这样的东西，并用适当的PHP代码替换它

***@unless 和 @endunless***

@unless是一种新的语法,在PHP中没有直接的等价语法对应,它是@if的反转,@unless(@condition)与\<?php if(!$condition)>相同,你可以在示例4-3中查看

{% code title="Example 4-3. @unless and @endunless" %}

```php
@unless ($user->hasPaid())
    You can complete your payment by switching to the payment tab.
@endunless
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://liseen315.gitbook.io/laravel/blade-mo-ban-yin-qing/kong-zhi-jie-gou/tiao-jian.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
