Hàm fileperms() trả về quyền truy cập (permissions) của file dưới dạng số nguyên (mode). Trả về FALSE nếu lỗi.
Cú pháp
fileperms(file_path)
Tham số
file_path – Đường dẫn file cần kiểm tra quyền.
Giá trị trả về
Trả về mode (integer) bao gồm loại file và quyền. Trả về FALSE nếu lỗi.
Ví dụ 1: Trả về mode số
<?php
echo fileperms("new.txt");
?>
Kết quả
33206
Ví dụ 2: Hiển thị quyền dạng octal (chmod style)
<?php
echo substr(sprintf('%o', fileperms('two.txt')), -4);
?>
Kết quả
0666
Lưu ý: Mode bao gồm cả file type (bit cao). Dùng (mode & 0777) để lấy quyền rwx. Kết quả bị cache.