Posted by: SEO Positive

Posted on: February 2, 2011 10:56 am

-

Difference between is_file() and file_exists()

One bug I fixed this week was down to one of the features of file_exists() function. File_exists(string $filename ) will return true if the filename points to a file or directory. Is_file( string $filename ) will return false if the given path is a directory. To check whether filename is actually a file, use is_file().

For both, $filename cannot be a relative path, so I always use document root to ensure an absolute path.


if( file_exists( $_SERVER{'DOCUMENT_ROOT'} . "/images/picture.jpg")) {
...
}
?>

SEO Positive

SEO Positive

SEO Positive Limited is one of the most trusted digital marketing agencies in the country, specialising in search engine optimisation, Pay Per Click account management and a diverse range of promotional services, including social media integration and online reputation management.
-
-
Authors
Categories
Archives
Blogroll