English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP Cours de Base

PHP Cours Avancé

PHP & MySQL

PHP Référence Manuel

Utilisation et exemple de la fonction PHP is_file()

PHP Filesystem Référence Manuel

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

Syntaxe

bool is_file ( string $filename )

Si le nom de fichier existe et est un fichier normal, cette fonction peut retourner true, sinon retourner false.

Exemple1

<?php
   $file = "/PhpProject/php/phptest.txt";
   if(is_file($file)) {
       echo("$file est un fichier normal");
   } else {
       echo("$file n'est pas un fichier normal");
   }
?>

Résultat de la sortie

/PhpProject/php/phptest.txt est un fichier normal

Exemple2

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

Résultat de la sortie

bool(false)
bool(false)

PHP Filesystem Référence Manuel