snipplets.dev/code/PHP/file_exists.php

28 lines
945 B
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/*
file_exists(string $filename): bool
Проверяет наличие указанного файла или каталога.
*/
/*
filename
Путь к файлу или каталогу.
На платформах Windows, для проверки наличия файлов на сетевых ресурсах,
используйте имена, подобные //computername/share/filename
или \\computername\share\filename.
Возвращает true, если файл или каталог, указанный параметром filename,
существует, иначе возвращает false.
*/
$filename = '/path/to/foo.txt';
if (file_exists($filename)) {
echo "Файл $filename существует";
} else {
echo "Файл $filename не существует";
}
?>