PHP - Fonction is_file ()

La fonction is_file () peut vérifier si le fichier spécifié est un fichier normal.

Syntaxe

bool is_file ( string $filename )

Cette fonction peut retourner true si le nom de fichier existe et est un fichier normal, ou false dans le cas contraire.

Exemple 1

<?php
   $file = "/PhpProject/php/phptest.txt";
   if(is_file($file)) {
       echo("$file is a regular file");
   } else {
       echo("$file is not a regular file");
   }
?>

Production

/PhpProject/php/phptest.txt is a regular file

Exemple-2

<?php
   var_dump(is_file("/PhpProject/simple.txt")) . "\n";
   var_dump(is_file("/PhpProject/php")) . "\n";
?>

Production

bool(false)
bool(false)