How to See if File 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
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

How to See if File Exists

Post by NewfieBilko »

Hey guys, simple request for code here. Just need logic that will check to see if a file is in a directory.

So something like

If "./include/thisfile.php exists = true"
then{
load this}
Else{
Load this}
EndIf

lol im sorry, i just love pseudo code
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

[php_man]is_file[/php_man]
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post by NewfieBilko »

thx bro
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post by NewfieBilko »

Hey bro, you know a way that you can:

Include AllFiles In A Specific Directory?

instead of going
include_once("./lang/$lang/error.php");
include_once("./lang/$lang/another.php");
include_once("./lang/$lang/anoteher.php");



I just wanna go

Loop While Not -1 /$langdir/
{
include_once(file1)
}




lol
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Loop through all of the files in the directory and insert each in an include. Be sure to check for '.' and '..' All the code to do this is in this forum.
User avatar
NewfieBilko
Forum Contributor
Posts: 189
Joined: Sun Jun 06, 2004 6:45 pm
Location: Newfoundland
Contact:

Post by NewfieBilko »

How can I pick up what files are in the directory? is_file doesn't do that, is_file checks to see if the designated file is there. How can i get a dirtectory list?
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Post Reply