Hàm is_wworthy () kiểm tra xem một tệp có thể ghi được hay không. Nó trả về TRUE nếu tệp tồn tại và có thể ghi được.
Cú pháp
is_writable(file_path)
Tham số
-
file_path - Đường dẫn của tệp sẽ được kiểm tra.
Quay lại
Hàm is_wworthy () trả về TRUE nếu tệp tồn tại và có thể ghi được.
Ví dụ
<?php
$file = "one.txt";
if(is_writable($file)) {
echo ("File is writeable!");
} else {
echo ("File is not writeable!");
}
?> Đầu ra
File is not writeable!
Hãy để chúng tôi xem một ví dụ khác.
Ví dụ
<?php
$file_permissions = fileperms("two.txt");
$res = sprintf("%o", $file_permissions);
$file = "two.txt";
if(is_writable($file)) {
echo ("File is writeable!");
echo(“Permission = $res”);
} else {
echo ("File is not writeable!");
echo(“Permission = $res”);
}
?> Đầu ra
File is writeable! Permission: 0777