[SOLVED] 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
HaVoC
Forum Commoner
Posts: 83
Joined: Sat Feb 07, 2004 7:20 am
Location: Smiths Falls, CA

[SOLVED] file_exists()

Post by HaVoC »

Code: Select all

<?php
$filename = "/modules/plugins/{$module}/{$module}.php";

if (file_exists($filename)){
	$module = $module;
}
else{
	$module = "error";
}
?>
There's the code, I don't know what's wrong. But it doesn't seem to execute anything after taht if statement. I echoed $filename to see if it outputted the correct information, it did.
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

No errors? Give us the result of viewtopic.php?p=65245#65245

Scorphus.
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

Have you tried echoing $module after your if statement?

Although I don't see any immediate errors in your code your if statement seems to be a bit odd to me. Unclear as to why it would not be written as....

Code: Select all

<?php
$filename = "/modules/plugins/{$module}/{$module}.php";

if (!file_exists($filename)){
   $module = 'error';
}
?>
Are you sure $filename should not be....

Code: Select all

$filename = "./modules/plugins/{$module}/{$module}.php";
User avatar
HaVoC
Forum Commoner
Posts: 83
Joined: Sat Feb 07, 2004 7:20 am
Location: Smiths Falls, CA

Post by HaVoC »

Thanks! You guys are great!
Post Reply