Q:

What is the single dot and double dots in the return value of function readdir() in php

I've been confused with the concept which descriped in php.net for the function is_dir(),it says

Tells whether the given filename is a directory

(1)It checks whether the given parameter is a directory or not,when I give it a path,it returns true on success,but it uses the term given filename,if I know it is filename(file returns false),why would I bothering checking it in the first place?
(2)Here comes the spot where I've been confused of,readdir returns the files resides inside the given folder,it returns the file names but also returns single dot and double dots while I looping the opendir(),so,what exactly does the dots means in the return value?

A:

Its very simple i think.
The singe dot represents the current directory and the double dot the parent directory.
In the root directory there would be no double dot. If you use the "ls -a" Linux command there will be the same output (single and double dot). This is very useful in some cases to be able to see which permissions are given in the parent or the current directory.
I don't know it for sure, but i think the readdir function uses the same interface which causes the dots. (maybe php simply uses the "ls" statement internally or something like that)
you could simply skip this two "files" in a loop with something like:
if ($file == "." or $file == "..") continue;

