PHP file_exists() function

This function is used to check whether a file or directory exists or not.

Syntax

file_exists(filename);

filename is the required parameter. This is the path to the file or directory.

This function always returns boolean values, either true or false. It returns true, if the given filename or directory exists and otherwise it returns false.

Example

<?php
    $filename = 'demo.txt';
    echo file_exists($filename);
?>

Output of the above code

1




Related PHP Functions

PHP array_reverse() function
PHP array_diff() function
PHP array_key_exists() function
PHP array_push() function
PHP array_search() function
PHP class_exists() function
PHP curl_setopt() function
PHP die() function
PHP dirname() function
PHP each() function
PHP explode() function
PHP file_exists() function
PHP function_exists() function
PHP getenv() function
PHP is_readable() function
PHP ksort() function
PHP mkdir() function
PHP ob_start() function
PHP parse_url() function
PHP str_repeat() function
PHP substr() function




Read more articles


General Knowledge



Learn Popular Language