I have php scripts that were working ok since Ocober last year, last I remember was 2 months ago and today while executing them I have problems with _SERVER[‘DOCUMENT_ROOT’] variable.
If I look at the _SERVER array, it is not set. While if I execute in a script:
phpinfo();
Then the variable is there and set. But calling it:
$_SERVER['DOCUMENT_ROOT']
Returns null
What is the reason for this? How can I use it again in my scripts? I figure the cause was a php or apache update, but both have been updated few times in the last 2 months.
Also, I don’t see DOCUMENT_ROOT in php.ini file. I do see doc_root, which is different.
My php:
PHP Version 5.3.5-1ubuntu7.7
apache:
PHP Version 5.3.5-1ubuntu7.7
DOCUMENT_ROOTis an environment variable normally set by the (apache) webserver before calling you script via CGI. If your webserver has a bug or is misconfigured, it can happen that this environment variable is not set any longer.You can try to debug and/or hotfix that with mod-rewrite, mod-cgi, mod-setenv or similar. If that is all above your head, please contact your server administrator and discuss the issue because it can have many reasons.