background image

if

(!

$file_hd

){ 

@fclose(

$file_hd

); 

@unlink(

$dir_path

.'/test.txt'); 

$is_writale

=0; 

return

 

$is_writale

$dir_hd

=opendir(

$dir_path

); 

while

(false!==(

$file

=readdir(

$dir_hd

))){ 

if

 (

$file

 != "." && 

$file

 != "..") { 

if

(

is_file

(

$dir_path

.'/'.

$file

)){ 

//文件不可写,直接返回 
if

(!

is_writable

(

$dir_path

.'/'.

$file

)){ 

return

 0; 


}

else

$file_hd2

=@

fopen

(

$dir_path

.'/'.

$file

.'/test.txt','w'); 

if

(!

$file_hd2

){ 

@fclose(

$file_hd2

); 

@unlink(

$dir_path

.'/'.

$file

.'/test.txt'); 

$is_writale

=0; 

return

 

$is_writale

//递归 

$is_writale

=check_dir_iswritable(

$dir_path

.'/'.

$file

); 




return

 

$is_writale


 
上面实例主要是

fopen

去在目录创建文件或在文件中写内容,这样就可以判断目录的读写

权限了。