How can I go out of the currect directory and access the test.php file?
I have tried the following:
But it does not work!
Also could you please let me know what is the difference between ./ and ../ ?
The following lines give the following results:
So whay the third one is empty?
Just ad another directory separator and perhaps move the desired path . For instance, it's good practice to use the constant:
realpath(__DIR__ . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "test.php");
. stands for "current directory" (has no practical effect in this case)
.. stands for "parent directory" and goes up one level.
One dot (.) means 'current directory', and two dots (..) means 'parent directory'.
Keep in mind that
__DIR__ will be the directory that the currently running php file is in. Check with an 'echo
__DIR__' first to make sure it's running from the directory you think it is.