I did a little comparison of /(include|require)(_once)?/ methods in PHP 5.2.5 (mostly to prove my coworker wrong).
This are values in microseconds, result is an average of 100 executions of each method
| | empty txt file | empty php file* | "real" php file** |
| include | 19.52 | 25.12 | 1247.75 |
| require | 40.42 | 45.81 | 1162.59 |
| include_once | 34.61 | 31.65 | 42.59 |
| require_once | 11.45 | 36.84 | 13.96 |
* only <?php and ?>
** with class definition and class_exists check
Code for the test:
function test($func, $file, $rpt = 1) { #clearstatcache();
$st=microtime(true);
for($t=0;$t<$rpt;$t++){ switch ($func) { case 'include':
include $file;
break;
case 'include_once':
include_once $file;
break;
case 'require':
require $file;
break;
case 'require_once':
require_once $file;
break;
default:
$func($file);
break;
}
}
return round(((microtime(true) - $st)*(1000*1000)) / $rpt, 2);
}