php relative and absolute paths

Lizard picture Lizard · Nov 18, 2009 · Viewed 12.6k times · Source

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?

Answer

Greg picture Greg · Nov 18, 2009

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

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

Then do

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