Path to a file using include() contains a "."

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
swraman
Forum Commoner
Posts: 58
Joined: Thu Nov 06, 2008 12:33 am

Path to a file using include() contains a "."

Post by swraman »

The line of code is:

include("./home/whatever.php")

what does the ./ mean?


I keep getting errors on that line, but it rins fine on another server. I know it isnt a code error, I found out what the problem was at a while back but I forgot.

The code ./ seems to intend to refer to the root directory of the site. The guy who made this site used it all over, it for some reason works fine on our server but it refuses to operate on my local machine.

thanks
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Path to a file using include() contains a "."

Post by onion2k »

. is the current working directory, so your script will look for whatever.php in a directory called "home" inside the directory it's currently running in, or in the /home directory of any directories in the include_path ( http://uk3.php.net/manual/en/ini.core.p ... clude-path ).

You can use other 'special' directories like / to get the document root, or .. to get the parent directory.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: Path to a file using include() contains a "."

Post by RobertGonzalez »

Every directory you are in (except the root directory I believe) will have two special, default directories in it. Those are "." and "..".

"." is the current directory you are in.

".." is the parent directory of the directory you are in (meaning it is the directory directly above the directory you are in).
Post Reply