0

What's the effective difference between:

include_once("../backend/example.php");

and

include_once("./backend/example.php");

My problem is that on my development-environment (XAMPP-Server) i had to use "./". But when i tried to upload my progress to the production-server, i had to change the paths to "../".

Thanks for your answer!

simplywing
  • 19
  • 4
  • Besides the duplicate question found, consult http://stackoverflow.com/questions/19272954/different-between-on-file-pathurl-in-asp-net – Funk Forty Niner Nov 02 '15 at 12:54

2 Answers2

1

./ refers to the current working directory (It's basically redundant, but it reiterates that you're starting in the current directory, and not at the root / folder, or in PHP's case it may try other folders to find the file.). To see which directory that is, you can use the getcwd() function. ../ basically instructs php to go back to the parent folder and then into backend/example.php.

A few examples:

  • Let's say this is your root, and your cwd: /var/www/mywebsite/
  • ../backend/example.php would refer to: /var/www/backend/example.php
  • ./backend/example.php (And also just backend/example.php) would refer to: /var/www/mywebsite/backend/example.php
Blue
  • 22,608
  • 7
  • 62
  • 92
-2
./= Actual folder
../= one folder back

you can define website path in config like this

$path = 'http://yourwebsite.com'

Than you can do like this :)

include($path"/backend/example.php");