What the different between ./ vs ../ vs /
I’m very confused, i tried to access PHP class in different level folder.
I have the following folder structure in webdir/asia/v1:
+db
class.database.php
config.database.php
+model
Application.php
text.php
In class.database.php, I want include config.database.php which is in the same folder.
In Application.php, I want include class.database.php which is in the level above.
In text.php, I want include Application.php.
How do I include correctly?
What I know for now is that to include files in the same folder, I can use this:
include('config.database.php');
What about the other two variations? I tried in Application.php to include class.database.php like this :
include_once('../class.database.php');
but it doesn’t work.
use
include(dirname(dirname(__FILE__)) . “/class.database.php”);
and see if it works.
Edit:
Here,dirname(__FILE__) gives you the current directory where dirname of “dirname(__FILE__)” takes you one step up in hierarachy of directory tree.