以下是一个使用PHP脚本来发送关机命令到服务器的实例。这个例子使用了`exec()`函数来执行系统的关机命令。
| 步骤 | PHP代码示例 |
|---|---|
| 1. | 确保你有足够的权限执行关机命令。 |
| 2. | 使用`exec()`函数来执行关机命令。 |
| 3. | 在执行关机命令前,你可能需要获取用户的确认。 |
```php

// 获取用户确认
if (isset($_POST['confirm'])) {
// 确认关机命令
$shutdownCommand = 'shutdown -h now';
// 执行关机命令
exec($shutdownCommand, $output, $return_var);
// 检查命令是否执行成功
if ($return_var == 0) {
echo "






