tags:

views:

78

answers:

3

what is the difference between ./folder-name/file.php and ../folder-name/file.php in php script?

A: 

../ is the directory below the directory you're currently in. ./ is the directory you're currently in. For example. If you are currently in /foo/bar. ../test.php is equivalent to /foo/test.php and ./test.php is equivalent to /foo/bar/test.php.

Sean
Directory hierarchy goes up, not down.
Jesse O'Brien
Apologies, yes, above rather than below, though the example is still sound.
Sean
+5  A: 

Path is interpreted by operation system you're using:

  • ./ - usually means current folder
  • ../ - usually means parent folder

If you're in folder /home/user, then

  • ./folder-name/file.php will point to /home/user/folder-name/file.php
  • but ../folder-name/file.php will point to /home/folder-name/file.php, which is 1 level up
Ivan Nevostruev
you have a mistake in your second example - still using single .
Marek Karbarz
@Zarembisty: Thanks you!
Ivan Nevostruev
+2  A: 

The first case, ./folder-name/file.php will start in your current directory.

The second case, ../folder-name/file.php will start from the parent directory.

cballou