It’s kind of a pain and not super clear coding in my opinion. Diving into my second PHP project, I was hoping to use the $_SERVER global variable and DOCUMENT_ROOT as below:
I’ve now given the whole $_SERVER[“DOCUMENT_ROOT”] some thought and now think that there may be one small issue. Let’s say I develop the site for www.thebestsiteever.com. However, it turns out that it needs to be all moved to a subdirectory (this is actually a possibility for the project), so that all of my files now reside in www.thebestsiteever.com/thebestfolderever/. If this does happen, wouldn’t I have to change all of my $_SERVER[“DOCUMENT_ROOT”] to reflect this with the additional layer? And, if this is the case, might there be a more “flexible” solution?
I recently started using constants for this. In my configuration file i declare constants with the right paths. If site moves I change soms constants.
But I don’t know If this is good practise