RE: [PHP] Testing existence of file in same directory as currents cript
| From: | Maxim Maletsky | Date: | Fri, 10 Nov 2000 09:36:02 +0000 |
| Subject: | RE: [PHP] Testing existence of file in same directory as currents cript | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-24642@lists.php.net to get a copy of this message | ||
if you play with files in different directories and need a full path use
DOCUMENT_ROOT :
$root = $DOCUMENT_ROOT;
$file = '/dir/file.php';
if(file_exists($root.$file))
echo 'It\'s here !!!';
$file is relative to the web server's root, and $DOCUMENT_ROOT is
predefining to you by apache what is the systems full path to your webserver
is.
in this way your application is portable enogh to go to be transported to
different web servers/sites.
-----Original Message-----
From: Robert Vetter [mailto:vetter@rundschau-onlinedienst.de]
Sent: Friday, November 10, 2000 6:31 PM
To: Rasmus Lerdorf
Cc: Stewart Macdonald; PHP List
Subject: Re: [PHP] Testing existence of file in same directory as
currentscript
Rasmus Lerdorf wrote:
>
> file_exists('filename')
>
> On Thu, 9 Nov 2000, Stewart Macdonald wrote:
>
> > Hi all,
> >
> > Long time listener, first time poster.
> >
> > I'm trying to see if a file exists in the same directory as the
> > currently-running script. I'm sure this is a really easy one, but, so
far,
> > nothing I have tried so far has worked, so far....
Page 253 of the PHP manual:
int file_exists (string filename)
Returns true if the file specified by filenameexists; 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.
Robert
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net