Home >Backend Development >PHP Tutorial >Example of php detecting file read-only, writable, and executable permissions

Example of php detecting file read-only, writable, and executable permissions

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-25 08:56:141047browse
  1. $myfile = "./test.txt";

  2. if (is_readable ($myfile)) {

  3. echo "This file Readable. ", "n";
  4. } else {
  5. echo "This file is not readable.", "/n";
  6. }
  7. if (is_writable ($myfile)) {
  8. echo "This file is writable." , "/n";
  9. } else {
  10. echo "This file is not writable.", "/n";
  11. }

  12. if (is_executable ($myfile)) {

  13. echo "This File is executable!", "n";
  14. } else {
  15. echo "This file does not have executable permissions", "n";
  16. }
  17. ?>

Copy code

Attached, detect the size of the file and learn how to use filesize.

  1. $myfile = "./test.txt";

  2. if (file_exists ($myfile)) {

  3. $checksize= filesize ($myfile);
  4. echo "$checksize";
  5. } else {
  6. echo "File does not exist!";
  7. }
  8. ?>

Copy code


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn