PHP is_file () function usage Guide, is_file usage guide
The Is_file () function checks whether the specified file name is normal.
Is_file-tells whether the filename is a regular file
Usage:
BOOL Is_file (string $filename) $file is a required parameter
Returns TRUE if the file exists and is a normal file.
Let's take a look at one example:
<?phpvar_dump (Is_file (' A_file.txt ')). "\ n"; Var_dump (Is_file ('/usr/bin/')). "\ n";? >
The example above will output:
BOOL (TRUE)
BOOL (FALSE)
Example two:
<?phpfunction Isfile ($file) {return Preg_match ('/^[^.^:^?^-][^:^?] *. (? i) '. Getexts (). ' $/', $file);//first character cannot be. : ? -subsequent characters can ' t be a:?//then A. Character and must end with one of your extentions//getexts () can is replaced with your extentions pattern}function getext S () {//list acceptable file extensions Herereturn ' (app|avi|doc|docx|exe|ico|mid|midi|mov|mp3|mpg|mpeg|pdf|psd|qt|ra |ram|rm|rtf|txt|wav|word|xls) ';} echo isfile ('/users/yourusername/sites/index.html ');? >
Example three:
<?phpfunction DeleteFolder ($path) {if ($handle =opendir ($path)) {while (false!== ($file =readdir ($handle))) {if ($ File<> "." and $file <> "..") {if (Is_file ($path. ') /'. $file)} {@unlink ($path. ') /'. $file);} if (Is_dir ($path. ' /'. $file)} {deletefolder ($path. ') /'. $file); @rmdir ($path. ' /'. $file);}}}}? >
This function will delete all files and folders.
The above mentioned is the whole content of this article, I hope you can like.
http://www.bkjia.com/PHPjc/996222.html www.bkjia.com true http://www.bkjia.com/PHPjc/996222.html techarticle in PHP, the Is_file () function uses the guide, is_file Use the Guide is_file () function to check if the specified file name is a normal document. Is_file-tells whether the filename is a regular file ...