# WP_CLI::confirm()

在执行破坏性操作前请求确认。

***

## 使用方法

    WP_CLI::confirm( $question, $assoc_args = [] )

<div>
<strong>$question</strong> (string) 提示前显示的问题。<br />
<strong>$assoc_args</strong> (array) 若提供 'yes' 则跳过提示。<br />
</div>

***

## 说明

如果对问题输入 'y'，脚本将继续执行。如果输入 'n' 或任何其他响应，脚本将退出。

```
# `wp db drop` 在删除数据库前请求确认。

WP_CLI::confirm( "确定要删除数据库吗？", $assoc_args );
```

*内部 API 文档随每个版本从 WP-CLI 代码库生成。如需改进，请提交拉取请求。*

***

## 相关函数

<ul>



<li><strong><a href="https://make.wordpress.org/cli/handbook/internal-api/wp-cli-utils-launch-editor-for-input/">WP_CLI\Utils\launch_editor_for_input()</a></strong> - 启动系统的 $EDITOR 供用户编辑文本。</li>


<li><strong><a href="https://make.wordpress.org/cli/handbook/internal-api/wp-cli-utils-get-flag-value/">WP_CLI\Utils\get_flag_value()</a></strong> - 返回标志值，若未设置则返回 $default 值。</li>


<li><strong><a href="https://make.wordpress.org/cli/handbook/internal-api/wp-cli-utils-report-batch-operation-results/">WP_CLI\Utils\report_batch_operation_results()</a></strong> - 报告对多个资源执行相同操作的结果。</li>


<li><strong><a href="https://make.wordpress.org/cli/handbook/internal-api/wp-cli-utils-parse-str-to-argv/">WP_CLI\Utils\parse_str_to_argv()</a></strong> - 将命令行参数字符串解析为 $argv 风格的变量。</li>


<li><strong><a href="https://make.wordpress.org/cli/handbook/internal-api/wp-cli-read-value/">WP_CLI::read_value()</a></strong> - 从多种格式读取值。</li>


<li><strong><a href="https://make.wordpress.org/cli/handbook/internal-api/wp-cli-has-config/">WP_CLI::has_config()</a></strong> - 确认全局配置参数存在。</li>


<li><strong><a href="https://make.wordpress.org/cli/handbook/internal-api/wp-cli-get-config/">WP_CLI::get_config()</a></strong> - 获取全局配置参数的值。</li>



</ul>