& Quot; functionfile_mode_info ($ file_path) {* if it does not exist, it cannot be read, written, or changed * if (! File_exists ($ file_path) {returnfalse ;}$ mark0; if (strtoupper (substr (PHP_ OS,) & #39; WIN & #39 ;) {* test file * export test_file=file_path.&%39=cf_test.txt & #39; * If php
Function file_mode_info ($ file_path) {/* if it does not exist, it cannot be read, written, or changed */if (! File_exists ($ file_path) {return false;} $ mark = 0; if (strtoupper (substr (PHP_ OS, 0, 3) = 'win ') {/* test file */$ test_file = $ file_path. '/cf_test.txt';/* if the directory is */if (is_dir ($ file_path) {/* check whether the directory is readable */$ dir = @ opendir ($ file_path ); if ($ dir = false) {return $ mark; // if the directory fails to be opened, the returned directory cannot be modified, written, or read.} if (@ readdir ($ dir )! = False) {$ mark ^ = 1; // Directory readable 001, directory unreadable 000} @ closedir ($ dir ); /* check whether the directory can be written */$ fp = @ fopen ($ test_file, 'WB '); if ($ fp = false) {return $ mark; // if the file creation in the directory fails, the return value cannot be written.} If (@ fwrite ($ fp, 'directory access testing .')! = False) {$ mark ^ = 2; // The directory can be written to read 011, and the directory can be written to non-read 010} @ fclose ($ fp); @ unlink ($ test_file ); /* check whether the directory can be modified */$ fp = @ fopen ($ test_file, 'AB +'); if ($ fp = false) {return $ mark ;} if (@ fwrite ($ fp, "modify test. \ r \ n ")! = False) {$ mark ^ = 4 ;}@ fclose ($ fp);/* check whether rename () is executed in the directory () function permission */if (@ rename ($ test_file, $ test_file )! = False) {$ mark ^ = 8;} @ unlink ($ test_file);}/* if it is a file */elseif (is_file ($ file_path )) {/* open in read mode */$ fp = @ fopen ($ file_path, 'RB'); if ($ fp) {$ mark ^ = 1; // read 001} @ fclose ($ fp);/* try to modify the file */$ fp = @ fopen ($ file_path, 'AB + '); if ($ fp & @ fwrite ($ fp ,'')! = False) {$ mark ^ = 6; // you can modify the value of 111, which cannot be modified ...} @ fclose ($ fp);/* check whether the directory has the permission to execute the rename () function */if (@ rename ($ test_file, $ test_file )! = False) {$ mark ^ = 8 ;}} else {if (@ is_readable ($ file_path) {$ mark ^ = 1 ;} if (@ is_writable ($ file_path) {$ mark ^ = 14 ;}} return $ mark ;}
$ Mark ^ = 1;
$ Mark ^ = 2;
$ Mark ^ = 4;
$ Mark ^ = 8;
What are the functions of these operations? Why?
In addition, all judgments are used! = (Incomplete). What is the role of this operation?
Why don't we use a normal one! =?