-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBASIC - FILE - is file readable_writable_executable.php
More file actions
44 lines (35 loc) · 1.32 KB
/
BASIC - FILE - is file readable_writable_executable.php
File metadata and controls
44 lines (35 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
/*
!!IS FILE READABLE, WRITABLE, EXECUTABLE!!
*is_readable - tells whether a file exists and is readable
> bool is_readable ( string $filename )
> returns TRUE if the file or directory specified by filename exists and is readable
> this function may return TRUE for directories. Use is_dir() to distinguish file and directory
*is_writable - tells whether the filename is writable
> bool is_writable ( string $filename )
> returns TRUE if the filename exists and is writable. the filename argument may
be a directory name allowing you to check if a directory is writable
*is_executable - tells whether the filename is executable
> bool is_executable ( string $filename )
> returns TRUE if the filename exists and is executable
*/
$file_name="file.txt";
/*Readable?*/
if(is_readable($file_name)) {
print ("The file $file_name is readable.<br />");
} else {
print ("The file $file_name is not readable.<br />");
}
/*Writable?*/
if(is_writeable($file_name)) {
print ("The file $file_name is writeable.<br />");
} else {
print ("The file $file_name is not writeable.<br />");
}
/*Executable?*/
if(is_executable($file_name)) {
print ("The file $file_name is executable.<br />");
} else {
print ("The file $file_name is not executable.<br />");
}
?>