Besides the performance increase (which is likely a pre-optimization in most cases*), it also protects from the (very odd) scenario where the environment's PHP configuration does not have the current directory (.
) as part of the include path.
* Benchmark of include
using a path that requires include_path
lookup versus a relative path that does not. Tested over 100000 iterations each
Results
include("include.php"): 8.3664200305939s
include("./include.php"): 8.3511519432068s
(8.3664200305939 - 8.3511519432068) / 100000 = 0.000000152680874s
Unless you're including hundreds or thousands of files, 0.0000001s is negligible at best.
Test code
define("MAX", 100000);
ob_start();
$i = MAX;
$_t = microtime(true);
do {
include("include.php");
} while ( --$i );
$_t = microtime(true) - $_t;
ob_end_clean();
echo "include(\"include.php\"): {$_t}s\n";
ob_start();
$i = MAX;
$_t = microtime(true);
do {
include("./include.php");
} while ( --$i );
$_t = microtime(true) - $_t;
ob_end_clean();
Test was conducted on a 2.16GHz Macbook 10.5.8 with PHP Version 5.2.9 (www.entropy.ch Release 7)