PHP/File Directory/file exists — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 07:04, 26 мая 2010
Содержание
Checking for Existence with file_exists()
<?
if ( file_exists ("data.txt") ) {
print "The file exists!";
}
?>
Checking the existence of a file
if (file_exists("/usr/local/htdocs/index.html")) {
print "Index file is there.";
} else {
print "No index file in /usr/local/htdocs.";
}
Checking Whether a File Exists
<?
if (file_exists("snapshot1.png")) {
print "Snapshot1.png exists!\n";
} else {
print "Snapshot1.png does not exist!\n";
}
?>
file_exists() function returns true if it does, and false otherwise.
Its syntax is: bool file_exists (string file)
<?
$filename = "data.txt";
if (! file_exists ($filename)) :
print "File $filename does not exist!";
endif;
?>
The file_exists.php script checks to see whether the file is there
<?php
$file_name="file_exists.php";
if(file_exists($file_name)) {
echo ("$file_name does exist.");
}
else {
echo ("$file_name does not exist.");
}
?>