I’ve taken over a php based site and trying to understand a bit. What I don’t get is the below in the index.php on my site. I’ve included just part of this. The top declares a variable to my understanding. But the use of DOCUMENT_ROOT below and also elsewhere causes PHP to assume a constant. I’m not sure it should be a constant as it looks to me like it’s declared as a variable. I can solve the messages by putting single quotes around DOCUMENT_ROOT I assume telling PHP (5.4) that it’s a constant. But then why declare it as a variable? If I change this in any way it breaks. If I define this is a constant and remove the variable declaration PHP doesn’t end up getting the path right for the include scripts it looks like. Having a tough time understanding. Most other scripts there are no variables declared. Just things like DOCUMENT_ROOT used and other what I assume are constants that can be solved by putting them in single quotes. Also have complaints about variables as they aren’t declared.
<?php $DOCUMENT_ROOT = "/home/mysite/domains/mysite/public_html"; include($_SERVER[DOCUMENT_ROOT] . "/inc/functions.php"); ?>
Notice: Use of undefined constant DOCUMENT_ROOT - assumed ‘DOCUMENT_ROOT’ in […][…] on line 5