Search code examples
phpinclude-path

php relative and absolute paths


I have read that when including a php file that using absolute paths has a faster processing time than relative paths.

What would you suggest to use?

include("includes/myscript.php");

or

include("/home/ftpuser/public_html/includes/myscript.php");

or even

set_include_path("/home/ftpuser/public_html/includes");
include("myscript.php");

Or is it something that I really shouldn't worry about?


Solution

  • I usually set a constant, either manually or like this:

    define('ROOT', dirname(__FILE__));
    

    Then do

    require ROOT . '/include/file.php';