tags:

views:

52

answers:

4

What is the difference between:

include("./somepath/class.php");

and

include("somepath/class.php");

+1  A: 

I don't see any difference. "." means current directory.

Petar Minchev
+2  A: 

There shouldn't be any difference, directory wise, since the former assumes relative directory structure. The only potential pitfall could be if "somepath" were actually a command to be run - some users expect to type a command for a local script file and assume it should run, when you actually have to run "./somepath" to invoke it. This, of course, only pertains to commands not on your $PATH.

rlotun
I am using it with PHP's include(); Should I use with or without the dot, or doesn't matter in this case?
FFish
A: 

. refers to the current working directory.

Sometimes you want to specify explicitly that what you want is in the current working directory, and that it is not from something in your path variable for example.

Brian R. Bondy
A: 

For example in PHP "somepath/somefile" is appended after paths specified in include_dir (for example: /home/var/; /home/bin/ ....) directive.

The second variant is more specific it says: search in current directory!

MartyIX