True directory or false directory

I have 2 urls.
The 1st one is http://dot.kr/x-test/directory1/
and
The other one is http://dot.kr/x-test/directory2/

There is a directory named "directory1’ in “http://dot.kr/x-test/
but
There is no directory named “directory2” in “http://dot.kr/x-test/

I like to find there is the directory “http://dot.kr/x-test/directory1/” when I don’t know it is there.
I like to find there is no the directory “http://dot.kr/x-test/directory1/” when I don’t know it is not there.

The would-be code below doesn’t work correctly but it will show what I want

[code]
$directoryBe=‘http://dot.kr/x-test/directory1’;

if ( $directoryBe is there) {
echo ‘true directory’;
} else {
echo ‘false directory’;
}
[/code].How can I make the would-be-code does work by your help?

$directoryBe='http://dot.kr/x-test/directory1';
if (file_exists($directoryBe)) {
    echo 'true directory';
} else {
    echo 'false directory';
}

http://php.net/manual/en/function.file-exists.php

You might also want to check that it is a directory as well as that it exists, using is_dir().

note of caution: An URL is not the same as a file or directory. The web server only maps an URL to one of these based on its configuration! (and it can map different URLs to the same file/directory, too. => Front-Controller-Pattern)

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.