array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'uk', ), 'this' => array ( 0 => 'function.is-file.php', 1 => 'is_file', 2 => 'Tells whether the filename is a regular file', ), 'up' => array ( 0 => 'ref.filesystem.php', 1 => 'Функції Файлової Системи', ), 'prev' => array ( 0 => 'function.is-executable.php', 1 => 'is_executable', ), 'next' => array ( 0 => 'function.is-link.php', 1 => 'is_link', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/filesystem/functions/is-file.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>
(PHP 4, PHP 5, PHP 7, PHP 8)
is_file — Tells whether the filename is a regular file
Tells whether the given file is a regular file. If filename is a
symbolic link, it will resolve the symlink and will give information about the referred file.
filenamePath to the file.
Returns true if the filename exists and is a regular file, false
otherwise.
Зауваження: Оскільки цілочисельний тип в PHP є знаковим, а багато платформ використовують 32-бітні цілі числа, деякі функції файлової системи можуть повертати неочікувані результати для файлів, розмір яких перевищує 2 ГБ.
Під час збоїв буде видаватись E_WARNING.
Приклад #1 is_file() example
<?php
var_dump(is_file('a_file.txt')) . "\n";
var_dump(is_file('/usr/bin/')) . "\n";
?>Поданий вище приклад виведе:
bool(true) bool(false)
Зауваження: Рузультати цієї функції кешуються. Докладніше: clearstatcache().
Починаючи з PHP 5.0.0, ця функція також може бути використана з деякими URL-обгортками. На сторінці Підтримувані протоколи та обгортки вказано, які обгортки підтримують сімейство функцій stat().