标签:
$path="../test";
if( is_dir($path) ) {
$dir=scandir($path);
foreach ($dir as $value) {
echo $value."<br>";
}
}else{
echo "目录路径错误";
}
|
函数原型
|
函数说明
|
举例
|
|
bool mkdir(string pathname)
|
新建一个指定的目录 |
mkdir("temp")
|
| bool rmdir(string dirname) |
删除所指定的目录,该目录必须是空的
|
rmdir("temp") |
|
string getcwd(void)
|
获取当前工作的目录 |
getcwd()
|
|
bool chdir(string directory)
|
改变当前目录为diretory |
echo getcwd().‘<br>‘;
chdir(‘../‘);
echo getcwd().‘<br>‘;
|
|
float disk_free_space(string directory)
|
返回目录中可用空间(bytes)。
被检查的文件必须通过服务器的文件系统。
|
disk_free_space(‘D:\\wampserver‘);
|
|
float disk_total_space(string directory)
|
返回目录的总空间大小(bytes)
|
disk_total_space(‘D:\\wampserver‘);
|
|
string readdir(resource handle)
|
返回目录中下一个文件的文件名(使用此函数时,目录必须是使用opendir()函数打开的)在PHP5之前,都是使用这个函数来浏览目录的
|
while(false!==($path==readdir($handle))){
echo $pah;
}
|
|
void rewinddir(resource handle)
|
将指定的目录重新指到目录的开头
|
rewinddir($handle)
|
$path="../";
if(is_dir($path)){
if($dire=opendir($path))
echo $dire;
}else{
echo "路径错误";
exit();
}
//.... //其他操作
closedir($dire);运行结果为:
Resource id #2
注:is_dir()函数用于判断当前路径是否是一个合法的目录。如果合法,返回true,否则返回false。
标签:
原文地址:http://blog.csdn.net/qq_28602957/article/details/51112485