• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.3 How to ignore variable ($DOCUMENT_ROOT) in PHP callback?

I have a PHP file in XenForo/Pages/<page> that has this line

The code does what it's supposed to do but I get "Undefined variable: DOCUMENT_ROOT " in my server error logs. How can I have XenForo ignore it?
Last edited:

Chris D

XenForo developer
Staff member
This is likely getting ignored because it has been posted in the styling forum :)

$DOCUMENT_ROOT is not a PHP variable that's available by default.

An undefined variable is simply that - undefined. It has not been explicitly defined and therefore it contains nothing. Undefined variables trigger a notice.

So you would either:

1) Define the variable first:
$DOCUMENT_ROOT = 'some/path';
Or, 2) Use the $_SERVER super global which contains a DOCUMENT_ROOT index: