温馨提示×

php rmdir怎样删除目录

PHP
小樊
81
2024-11-28 12:07:40
栏目: 编程语言

在PHP中,要使用rmdir()函数删除一个空目录,您需要确保该目录是空的

<?php
$directory = 'path/to/your/directory';

if (is_dir($directory) && rmdir($directory)) {
    echo "Directory '$directory' has been removed successfully.";
} else {
    echo "Failed to remove directory '$directory'. It may not be empty or does not exist.";
}
?>

请将path/to/your/directory替换为您要删除的目录的实际路径。如果目录为空并且成功删除,您将看到成功消息。否则,您将看到失败消息。

0