I have few files (containing some classes and functions) outside the "public_html" folder on my webserver and I would like to include these files into my script.
I know how to do this relative paths such as "include ../somefile.php", but my script runs also on some subfolders and these relative paths get broken when they are not in the "public_html root".
I don't want write different script with different paths for each subfolder and their subfolders, so I figured out a solution. But is this a good solution or do you find this too difficult:
$root= ereg_replace('public_html','',getenv("DOCUMENT_ROOT"));
include $root."somefile.php";
And is this a secure solution?