I'm trying to get the root of my app in order to include files starting from it.. I use this
include_once $_SERVER['DOCUMENT_ROOT'].'/includes/myfile.php'
It show this error:
Warning: include_once(/usr/local/apache/htdocs/includes/db.php) [function.include-once]: failed to open stream: Permission denied .....etc
Warning: include_once() [function.include]: Failed opening '/usr/local/apache/htdocs/includes/myfile.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/usernamehere/public_html/includes/parentfile.php on line 14
but when use part of $_SERVER['SCRIPT_FILENAME'] (which equals '/home/username/public_html/parentfile.php') like this:
include_once '/home/username/public_html/includes/myfile.php';
It works correctly with no errors.
Is it a permission issue from server administrator side? Or I can solve it from mine?
$_SERVER['DOCUMENT_ROOT']
is for the whole web server, but not per-userpublic_html
directories. – Giacomo1968