The Is_file () function checks whether the specified filename is a normal file.
Is_file-tells whether the filename is a regular file
Usage:
BOOL Is_file (string $filename) $file for required parameters
Returns TRUE if the file exists and is a normal file.
Let's take a look at one example first:
<?php
var_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:
<?php
function Isfile ($file) {return
preg_match ('/^[^.^:^?^-][^:^?] *. (? i) '. Getexts (). ' $/', $file);
The character cannot is. : ? -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 getexts () {
//list acceptable file extensions here
-return ' (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:
<?php
function 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 deletes all files and folders.
The above mentioned is the entire content of this article, I hope you can enjoy.