Re: include vs require
| From: | Fabien MARTY | Date: | Sun, 23 Feb 2003 21:49:41 +0000 |
| Subject: | Re: include vs require | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-13695@lists.php.net to get a copy of this message | ||
> > Note the use of include_once AND CERTAINLY NOT REQUIRE_ONCE !!!
>
> Note that after 4.0.2 include and require are identical
> except the way how they handle failure. So using include
> in conditional blocks does not seem to aply anymore.
Hum... my doc was a little old... :)
But it doesn't change the problem... If you include cache in IT, you load PEAR.php at every
time (even if the page is cached). So if you are looking for speed, it's better to keep the
caching system away from the template system. Just a little example about perfs :
<?php
require_once('Cache/Lite.php');
$foo = false;
if ($foo) {
require_once('PEAR.php');
echo('Nothing !');
}
?>
ab -c 10 -n 1000
=> Requests per second: 266.12 [#/sec] (mean)
whereas :
<?php
require_once('Cache/Lite.php');
require_once('PEAR.php');
$foo = false;
if ($foo) {
echo('Nothing !');
}
?>
ab -c 10 -n 1000
=> Requests per second: 132.14 [#/sec] (mean)
The first system is 2 times faster !!!
Fab