I have a folder that looks like this sorta
/optik
|- shadow
- auth.ini
|- htdocs
|- index.php
and I have an actual directory
/
|- skel
|- include.php
now, i made a symbolic link shadow from skel, so what ever I put in skel will appear in the shadow folder. I did this because I have dynamic files in skel that I would be changing from time to time, so i didn’t want to keep having duplicate copies of the contents of skel in each of my users folders. So I thought of making a shortcut link to it.
But now I was looking to see if in my index.php i could do something like this
index.php
<?
include "/optik/shadow/include.php";
// content
and in my include.php
<?
include "../auth.ini";
// some stuff with auth.ini
My goal is that I want to know if I can use the symbolic link like an actual dir in PHP’s eyes. Since from the symbolic links perspective it would need to go up 1 directory to access auth.ini, but in the actual skel directory that file doesn’t exist and I would need to specify the entire directory path to my auth.ini. But since the user folders will all differ its impossible to know what directory path to specify.
How can I get something like this to work?
PHP should respect symlinks and follow them as if they were standard directories.
However, you are still working from the original directory in which
index.phpresides. This means that theinclude "../auth.ini";call will be looking in/optik(the directory abovehtdocs) rather than the directory above that in which the included file resides.You can use a combination of realpath() and dirname() to calculate the actual canonical paths of the files you want to get at.