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

ix2013

Member
I have a PHP file in XenForo/Pages/<page> that has this line
include("$DOCUMENT_ROOT/include/config.php");

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:
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:
PHP:
$DOCUMENT_ROOT = 'some/path';
include("$DOCUMENT_ROOT/include/config.php");

Or, 2) Use the $_SERVER super global which contains a DOCUMENT_ROOT index:
PHP:
include("$_SERVER[DOCUMENT_ROOT]/include/config.php");
 
Back
Top Bottom