Tutorials Point


  Learning PHP
  Advanced PHP
  PHP Function Reference
  PHP Useful Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

PHP Function file_exists()


previous

Advertisements

Syntax

bool file_exists ( string $filename );

Definition and Usage

Checks whether a file or directory exists.

Paramters

ParameterDescription
filenamePath to the file or directory.

Return Value

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

Example

Following is the usage of this function:

<?php
$filename = '/home/httpd/index.htm';

if (file_exists($filename)) {
    echo "The file $filename exists";
} else {
    echo "The file $filename does not exist";
}
?>

previous Printer Friendly

Advertisements


  

Advertisements