Recognise If A Directory Exists?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
JustinMs66
Forum Contributor
Posts: 127
Joined: Sun Sep 03, 2006 4:18 pm

Recognise If A Directory Exists?

Post by JustinMs66 »

i need the PHP code for recognising if a directory named "userfiles" exists.

i also need the PHP code for redirecting to another PHP file.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Difficulty digging them out? file_exists() and is_dir() and header(). Amazing.
User avatar
JustinMs66
Forum Contributor
Posts: 127
Joined: Sun Sep 03, 2006 4:18 pm

Post by JustinMs66 »

ok so i did this:

Code: Select all

<?php
if (is_dir('userfiles')){
echo "userfile DOES exist";
else
echo "userfiles does NOT exist";
?>
and it outputs this:
Parse error: syntax error, unexpected T_ELSE in /index.php on line 4
but i can't see what i did wrong! please help!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

braces...
User avatar
JustinMs66
Forum Contributor
Posts: 127
Joined: Sun Sep 03, 2006 4:18 pm

Post by JustinMs66 »

... braces? do you mean brackets? if so, where do i put them?
toasty2
Forum Contributor
Posts: 361
Joined: Wed Aug 03, 2005 10:28 am
Location: Arkansas, USA

Post by toasty2 »

Code: Select all

<?php
if (is_dir('userfiles'))
     {
     echo "userfiles DOES exist";
     } //You were missing this brace
else
     { //and this brace
     echo "userfiles does NOT exist";
     } //and this brace.
?>
Post Reply