PHP - Function file_exists()


Advertisements


Syntax

bool file_exists ( string $file_open );

Definition and Usage

Checks whether a file or directory exists.

Parameters

Sr.No Parameter & Description
1

file_open

Path to the file or directory.

Return Value

Returns TRUE if the file or directory specified by file_open exists; FALSE otherwise.

Example

Following is the usage of this function −

<?php
   $file_open = '/home/httpd/index.htm';
   
   if (file_exists($file_open)) {
      echo "The file $file_open exists";
   }else {
      echo "The file $file_open does not exist";
   }
?>

php_function_reference.htm

Advertisements