★ wanayoo — archive 1999 http://www.php.net/manual/function.file-exists.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to Filesystem
Quick Reference
German version of this pageJapanese version of this pageItalian version of this pageFrench version of this pageHungarian version of this page
Filesystem
* basename
* chgrp
* chmod
* chown
* clearstatcache
* copy
* delete
* dirname
* diskfreespace
* fclose
* feof
* fgetc
* fgetcsv
* fgets
* fgetss
* file
* file_exists
* fileatime
* filectime
* filegroup
* fileinode
* filemtime
* fileowner
* fileperms
* filesize
* filetype
* flock
* fopen
* fpassthru
* fputs
* fread
* fscanf
* fseek
* fstat
* ftell
* ftruncate
* fwrite
* set_file_buffer
* is_dir
* is_executable
* is_file
* is_link
* is_readable
* is_writeable
* link
* linkinfo
* mkdir
* pclose
* popen
* readfile
* readlink
* rename
* rewind
* rmdir
* stat
* lstat
* realpath
* symlink
* tempnam
* touch
* umask
* unlink
Manual: file_exists
View the source code for this pageSearch the site



Previous page
 file
 Updated
Sat, 12 Aug 2000
fileatime 
Next page


file_exists

(PHP3 , PHP4 )

file_exists -- Check whether a file exists

Description

int file_exists (string filename)

Returns true if the file specified by filename exists; false otherwise.

file_exists() will not work on remote files; the file to be examined must be accessible via the server's filesystem.

The results of this function are cached. See clearstatcache() for more details.


User Contributed Notes: file_exists


ted@3bits.com
16-Sep-1999 05:58
the description of this function should read:

bool file_exists(string filename);



webconnect@aon.at
13-Jan-2000 11:25
Also, ich habe jetzt verstanden, dass man mit diesem Befehl keine URL ueberpruefen kann. Aber ich suche einen genau solchen Befehl fuer eine Suchmaschine. Gibt es so etwas - Bitte e-mail an mich, wenn jemand etwas weiss !


siggma@siggma.net
31-Jan-2000 06:54
My limited knowledge of German combined with my limited knowledge of English, anyhow, I have the same question:
Is there a function to check is a given URL exists. I tried this one, but nope...



ckernan@tibus.net
01-Feb-2000 07:27
Use fopen function to check if a given URL exists. See note added by
chopin@csone.kaist.ac.kr within documentation for fopen for an example.



lnk@wastelan.com
17-Feb-2000 07:23
file_exists does not traverse the include path.


larryo@buffnet.net
25-Feb-2000 06:12
file_exists() also works with directory names - use this instead of is_dir() and is_file() to verify something's existence.


kevin@imssoft.com
22-Mar-2000 02:37
Does php provide a function that supports globbing like
file_exists("f*")? I'm pretty sure it doesn't.



trollboy@defnet.com
17-Apr-2000 03:53
How do I create a blank txt file though? I want to have file_exists chekc for a file and if it doesn't exits, then I want that file created.



21-Apr-2000 03:27
<pre>
if (!file_exists($file) {
$fp = fopen("temp.phtml", "w");
fputs($fp, $entry);
fclose($fp);
copy("temp.phtml", $catgr . "/" . $newfile);
chmod($catgr . "/" . $newfile, 0777);
</pre>
this should create a file with whatever data you want as the body. I've found that sometime the file permission are off, so i'd have to open an empty file which i leave on the server, then copy that file to the newfile, using chmod to set the permission so i can edit it later.



mstoner@psicorps.com
21-Apr-2000 03:28
<pre>
if (!file_exists($newfile) {
$fp = fopen("temp.phtml", "w");
fputs($fp, $entry);
fclose($fp);
copy("temp.phtml",$newfile);
chmod($catgr . "/" . $newfile, 0777);
</pre>
this should create a file with whatever data you want as the body. I've found that sometime the file permission are off, so i'd have to open an empty file which i leave on the server, then copy that file to the newfile, using chmod to set the permission so i can edit it later.



ben@burt.pnpt.com
14-Jul-2000 10:29
is there a way to get a list of files in a directory? (ls) I want to delete any files that aren't in a given database.


saxey777@yahoo.com
17-Jul-2000 04:07
yeah, there's a beautiful way to get the content of a directory (files, dirs etc.)
this is a PHP xommand: readdir();
code example is:
&lt;?
$handle=opendir('.');
echo "files:"; echo "
";
while ($file = readdir($handle)) {
echo "$file"; echo "
";
}
?>



 About Notes


Previous page
 file
 Updated
Sat, 12 Aug 2000
fileatime 
Next page





Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.