Reputation: 2323
EDIT : Damn... It was all about Path to the file and somehow I didn't thought about restructuring :| thanks to @Machavity I found the problem.
What is wrong with this code ?
If $foo
is set and file exist file_exist()
result should be 1.
else if $foo
is set but file does not exist file_exist()
result should be 2.
else result should be 3.
But I am only getting result 2 for all the three conditions. There gotta be something wrong with the second part of the elseif.
if ( isset ( $foo ) && file_exists ( 'bar.php' ) )
{
echo '1';
}
else if ( isset ( $foo ) && ( ! file_exists ( 'bar.php' ) ) )
{
echo '2';
}
else
{
echo '3';
}
Upvotes: 0
Views: 62
Reputation: 31624
Normally I don't like wrapping but try restructuring like this. This way you have a better idea of what's failing
if(isset($foo)) {
if(file_exists('bar.php')) {
echo '1';
} else {
echo '2';
}
} else {
echo '3';
}
Upvotes: 1