1. 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?

Discussion in 'Styling and Customization Questions' started by ix2013, Mar 27, 2014.

  1. ix2013

    ix2013 Member

    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: Mar 27, 2014
  2. ix2013

    ix2013 Member

    If there isn't a way I can always use ../ but I'd just like to know.
  3. Chris D

    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:
  4. ix2013

    ix2013 Member

    Thank you. I knew I was missing something..

Share This Page