Search code examples
phpcpanelinclude-path

PHP Includes requiring $_SERVER['DOCUMENT_ROOT'] how to disable to only use file location?


Is there a way to disable/negate the use of $_SERVER['DOCUMENT_ROOT'] when including my php files? I would prefer

require '/somedirectory/somefile.php'; 

instead of

$_SERVER['DOCUMENT_ROOT'].'/somedirectory/somefile.php';

Running Centos and cPanel.

Or is this something that will always be required when writing my php code?


Solution

  • Just use:

    require './somedirectory/somefile.php';